public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-7258] d: Merge upstream dmd 52844d4b1, druntime dbd0c874, phobos 896b1d0e1.
@ 2022-02-16 10:15 Iain Buclaw
  0 siblings, 0 replies; only message in thread
From: Iain Buclaw @ 2022-02-16 10:15 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d75691877c4a7521a995d2601021fcaf30f65d94

commit r12-7258-gd75691877c4a7521a995d2601021fcaf30f65d94
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sun Feb 13 20:17:53 2022 +0100

    d: Merge upstream dmd 52844d4b1, druntime dbd0c874, phobos 896b1d0e1.
    
    D front-end changes:
    
        - Parsing and compiling C code is now possible using `import'.
        - `throw' statements can now be used as an expression.
        - Improvements to the D template emission strategy when compiling
          with `-funittest'.
    
    D Runtime changes:
    
        - New core.int128 module for implementing intrinsics to support
          128-bit integer types.
        - C bindings for the kernel and C runtime have been better separated
          to allow compiling for hybrid targets, such as kFreeBSD.
    
    Phobos changes:
    
        - The std.experimental.checkedint module has been renamed to
          std.checkedint.
    
    gcc/d/ChangeLog:
    
            * d-builtins.cc (d_build_builtins_module): Set purity of DECL_PURE_P
            functions to PURE::const_.
            * d-gimplify.cc (bit_field_ref): New function.
            (d_gimplify_modify_expr): Handle implicit casting for assignments to
            bit-fields.
            (d_gimplify_unary_expr): New function.
            (d_gimplify_binary_expr): New function.
            (d_gimplify_expr): Handle UNARY_CLASS_P and BINARY_CLASS_P.
            * d-target.cc (Target::_init): Initialize bitFieldStyle.
            (TargetCPP::parameterType): Update signature.
            (Target::supportsLinkerDirective): New function.
            * dmd/MERGE: Merge upstream dmd 52844d4b1.
            * expr.cc (ExprVisitor::visit (ThrowExp *)): New function.
            * types.cc (d_build_bitfield_integer_type): New function.
            (insert_aggregate_bitfield): New function.
            (layout_aggregate_members): Handle inserting bit-fields into an
            aggregate type.
    
    libphobos/ChangeLog:
    
            * Makefile.in: Regenerate.
            * libdruntime/MERGE: Merge upstream druntime dbd0c874.
            * libdruntime/Makefile.am (DRUNTIME_CSOURCES): Add core/int128.d.
            (DRUNTIME_DISOURCES): Add __builtins.di.
            * libdruntime/Makefile.in: Regenerate.
            * src/MERGE: Merge upstream phobos 896b1d0e1.
            * src/Makefile.am (PHOBOS_DSOURCES): Add std/checkedint.d.
            * src/Makefile.in: Regenerate.
            * testsuite/testsuite_flags.in: Add -fall-instantiations to
            --gdcflags.

Diff:
---
 gcc/d/d-builtins.cc                                |    2 +-
 gcc/d/d-gimplify.cc                                |   71 +
 gcc/d/d-target.cc                                  |   33 +-
 gcc/d/dmd/MERGE                                    |    2 +-
 gcc/d/dmd/README.md                                |    1 +
 gcc/d/dmd/access.d                                 |   10 +-
 gcc/d/dmd/astenums.d                               |   45 +-
 gcc/d/dmd/attrib.d                                 |   58 +
 gcc/d/dmd/blockexit.d                              |   79 +-
 gcc/d/dmd/canthrow.d                               |   85 +-
 gcc/d/dmd/constfold.d                              |   20 +-
 gcc/d/dmd/cparse.d                                 |  206 +-
 gcc/d/dmd/cppmangle.d                              |   13 +-
 gcc/d/dmd/dcast.d                                  |   12 +-
 gcc/d/dmd/dclass.d                                 |    1 +
 gcc/d/dmd/declaration.d                            |   10 +-
 gcc/d/dmd/denum.d                                  |    3 +-
 gcc/d/dmd/dinterpret.d                             |   31 +-
 gcc/d/dmd/dscope.d                                 |    3 +-
 gcc/d/dmd/dsymbol.d                                |    2 +-
 gcc/d/dmd/dsymbolsem.d                             |   25 +-
 gcc/d/dmd/dtemplate.d                              |  176 +-
 gcc/d/dmd/dtoh.d                                   |    1 +
 gcc/d/dmd/escape.d                                 |   35 +-
 gcc/d/dmd/expression.d                             |   38 +-
 gcc/d/dmd/expression.h                             |   12 +-
 gcc/d/dmd/expressionsem.d                          |  110 +-
 gcc/d/dmd/func.d                                   |    2 +-
 gcc/d/dmd/globals.d                                |   44 +-
 gcc/d/dmd/globals.h                                |    1 +
 gcc/d/dmd/hdrgen.d                                 |   11 +
 gcc/d/dmd/id.d                                     |    6 +-
 gcc/d/dmd/json.d                                   |    3 +-
 gcc/d/dmd/mtype.d                                  |  152 +-
 gcc/d/dmd/mtype.h                                  |    1 -
 gcc/d/dmd/nogc.d                                   |    1 +
 gcc/d/dmd/nspace.d                                 |    1 +
 gcc/d/dmd/objc.d                                   |   58 -
 gcc/d/dmd/opover.d                                 |   10 +-
 gcc/d/dmd/optimize.d                               |    4 +-
 gcc/d/dmd/parse.d                                  |  605 ++--
 gcc/d/dmd/parsetimevisitor.d                       |    1 +
 gcc/d/dmd/root/README.md                           |    1 +
 gcc/d/dmd/root/optional.d                          |    2 +-
 gcc/d/dmd/sideeffect.d                             |   28 +-
 gcc/d/dmd/statement.d                              |    1 -
 gcc/d/dmd/statement.h                              |    2 +-
 gcc/d/dmd/statementsem.d                           |   67 +-
 gcc/d/dmd/staticcond.d                             |   14 +-
 gcc/d/dmd/target.d                                 |   24 +-
 gcc/d/dmd/target.h                                 |    7 +-
 gcc/d/dmd/template.h                               |    1 +
 gcc/d/dmd/tokens.d                                 |    5 +-
 gcc/d/dmd/tokens.h                                 |    1 +
 gcc/d/dmd/traits.d                                 |   39 +-
 gcc/d/dmd/transitivevisitor.d                      |    6 +
 gcc/d/dmd/typesem.d                                |    6 +-
 gcc/d/dmd/visitor.h                                |    2 +
 gcc/d/expr.cc                                      |    8 +
 gcc/d/types.cc                                     |   77 +-
 gcc/testsuite/gdc.test/compilable/casttuple.d      |   31 +
 .../gdc.test/compilable/deprecated_override.d      |   97 +
 .../gdc.test/compilable/extra-files/header1.d      |    6 +
 gcc/testsuite/gdc.test/compilable/fix17635.d       |   16 +
 gcc/testsuite/gdc.test/compilable/fix22291.d       |  134 +
 .../gdc.test/compilable/imports/cstuff3.c          |    6 +
 .../gdc.test/compilable/imports/imp22625.c         |    1 +
 .../gdc.test/compilable/imports/imp22665.c         |    1 +
 .../gdc.test/compilable/imports/test22685b.d       |    5 +
 .../gdc.test/compilable/imports/test22685c.d       |    3 +
 gcc/testsuite/gdc.test/compilable/issue22130.d     |   12 +
 gcc/testsuite/gdc.test/compilable/noreturn1.d      |    3 +-
 gcc/testsuite/gdc.test/compilable/test13008.d      |    6 +-
 gcc/testsuite/gdc.test/compilable/test18771.d      |    2 +-
 gcc/testsuite/gdc.test/compilable/test19609.d      |    2 +-
 gcc/testsuite/gdc.test/compilable/test19873.d      |    2 +-
 gcc/testsuite/gdc.test/compilable/test21299a.d     |    2 +-
 gcc/testsuite/gdc.test/compilable/test22619.d      |   11 +
 gcc/testsuite/gdc.test/compilable/test22625.d      |    4 +
 gcc/testsuite/gdc.test/compilable/test22646.d      |   21 +
 gcc/testsuite/gdc.test/compilable/test22665.d      |   22 +
 gcc/testsuite/gdc.test/compilable/test22676.d      |   25 +
 gcc/testsuite/gdc.test/compilable/test22685.d      |   11 +
 gcc/testsuite/gdc.test/compilable/test55.d         |    3 +-
 gcc/testsuite/gdc.test/compilable/testcstuff3.d    |    4 +
 gcc/testsuite/gdc.test/compilable/testos.d         |    7 +
 .../{compilable => fail_compilation}/b16967.d      |    5 +-
 gcc/testsuite/gdc.test/fail_compilation/bug5096.d  |   14 +
 gcc/testsuite/gdc.test/fail_compilation/bug9631.d  |    4 +-
 .../gdc.test/fail_compilation/casttuple.d          |   25 +
 .../gdc.test/fail_compilation/constraints_aggr.d   |    4 +-
 .../gdc.test/fail_compilation/constraints_func1.d  |   26 +-
 .../gdc.test/fail_compilation/constraints_func2.d  |   28 +-
 .../gdc.test/fail_compilation/constraints_func3.d  |   12 +-
 .../gdc.test/fail_compilation/constraints_func4.d  |   12 +-
 .../gdc.test/fail_compilation/diag11819b.d         |   38 +-
 .../gdc.test/fail_compilation/diag13333.d          |    2 +-
 .../gdc.test/fail_compilation/diag13942.d          |    2 +-
 .../gdc.test/fail_compilation/diag16271.d          |    2 +-
 .../gdc.test/fail_compilation/diag16977.d          |    2 +-
 .../gdc.test/fail_compilation/diag19225.d          |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/diag8101.d |    6 +-
 gcc/testsuite/gdc.test/fail_compilation/diag8648.d |    6 +-
 gcc/testsuite/gdc.test/fail_compilation/diag8684.d |    5 +-
 gcc/testsuite/gdc.test/fail_compilation/diag9004.d |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/diag9420.d |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/diagin.d   |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/dip25.d    |    2 +-
 .../gdc.test/fail_compilation/fail10964.d          |    4 +-
 .../gdc.test/fail_compilation/fail11453a.d         |    2 +-
 .../gdc.test/fail_compilation/fail11453b.d         |    2 +-
 .../gdc.test/fail_compilation/fail11653.d          |    5 +-
 .../gdc.test/fail_compilation/fail12744.d          |    4 +-
 gcc/testsuite/gdc.test/fail_compilation/fail132.d  |    2 +-
 .../gdc.test/fail_compilation/fail14669.d          |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/fail162.d  |    2 +-
 .../gdc.test/fail_compilation/fail18417.d          |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/fail196.d  |   33 +-
 .../gdc.test/fail_compilation/fail19609.d          |    2 +-
 .../gdc.test/fail_compilation/fail19897.d          |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/fail207.d  |    5 +-
 .../gdc.test/fail_compilation/fail20730b.d         |    2 +-
 .../gdc.test/fail_compilation/fail21830.d          |    2 +-
 .../gdc.test/fail_compilation/fail21831.d          |    2 +-
 .../gdc.test/fail_compilation/fail21832.d          |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/fail220.d  |    2 +-
 .../gdc.test/fail_compilation/fail22035.d          |    2 +-
 .../gdc.test/fail_compilation/fail22084.d          |    2 +-
 .../gdc.test/fail_compilation/fail22133.d          |    2 +-
 .../gdc.test/fail_compilation/fail22144.d          |    2 +-
 .../gdc.test/fail_compilation/fail22749.d          |   13 +
 gcc/testsuite/gdc.test/fail_compilation/fail236.d  |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/fail276.d  |    2 +-
 .../gdc.test/fail_compilation/fail4269e.d          |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/fail59.d   |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/fail60.d   |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/fail8009.d |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/fail95.d   |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/fix17635.d |   23 -
 .../gdc.test/fail_compilation/ice11856_0.d         |    2 +-
 .../gdc.test/fail_compilation/ice11856_1.d         |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/ice14130.d |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/ice14907.d |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/ice6538.d  |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/ice9284.d  |    2 +-
 .../gdc.test/fail_compilation/imports/imp18554.d   |    4 -
 .../gdc.test/fail_compilation/imports/imp22749.c   |    4 +
 .../gdc.test/fail_compilation/issue21936.d         |   32 -
 gcc/testsuite/gdc.test/fail_compilation/noreturn.d |    4 +-
 .../gdc.test/fail_compilation/noreturn2.d          |   51 +
 .../gdc.test/fail_compilation/objc_class2.d        |    2 +-
 .../gdc.test/fail_compilation/objc_class3.d        |    2 +-
 .../gdc.test/fail_compilation/objc_non_objc_base.d |    2 +-
 gcc/testsuite/gdc.test/fail_compilation/reg6769.d  |    2 +-
 .../gdc.test/fail_compilation/reserved_version.d   |    3 +
 .../fail_compilation/reserved_version_switch.d     |    3 +
 .../gdc.test/fail_compilation/retscope5.d          |    2 +-
 .../gdc.test/fail_compilation/test15191.d          |    2 +-
 .../gdc.test/fail_compilation/test16188.d          |    2 +-
 .../gdc.test/fail_compilation/test16589.d          |    4 +-
 .../gdc.test/fail_compilation/test17284.d          |    2 +-
 .../gdc.test/fail_compilation/test17450.d          |    2 +-
 .../gdc.test/fail_compilation/test18554.d          |   24 -
 .../gdc.test/fail_compilation/test19107.d          |    2 +-
 .../gdc.test/fail_compilation/test19193.d          |    2 +-
 .../gdc.test/fail_compilation/test21912.d          |    2 +-
 .../gdc.test/fail_compilation/test22298.d          |   30 +
 .../gdc.test/fail_compilation/test22541.d          |   18 +
 .../gdc.test/fail_compilation/test22709.d          |   29 +
 gcc/testsuite/gdc.test/fail_compilation/test3818.d |   27 +
 gcc/testsuite/gdc.test/fail_compilation/test9701.d |    2 +-
 .../gdc.test/fail_compilation/test9701b.d          |    2 +-
 .../gdc.test/fail_compilation/traits_parameters.d  |   10 +
 gcc/testsuite/gdc.test/runnable/a18.d              |    2 +-
 gcc/testsuite/gdc.test/runnable/a19.d              |    2 +-
 gcc/testsuite/gdc.test/runnable/b26.d              |    2 +-
 gcc/testsuite/gdc.test/runnable/class_opCmp.d      |   25 +
 gcc/testsuite/gdc.test/runnable/fix22624.d         |   19 +
 gcc/testsuite/gdc.test/runnable/ice15138.d         |    2 +-
 gcc/testsuite/gdc.test/runnable/ice15176.d         |    2 +-
 gcc/testsuite/gdc.test/runnable/ice15200.d         |    2 +-
 gcc/testsuite/gdc.test/runnable/imports/imp22624.c |    6 +
 gcc/testsuite/gdc.test/runnable/issue16995.d       |    2 +-
 gcc/testsuite/gdc.test/runnable/link10425.d        |    2 +-
 gcc/testsuite/gdc.test/runnable/link11069b.d       |    2 +-
 gcc/testsuite/gdc.test/runnable/link11395.d        |    2 +-
 gcc/testsuite/gdc.test/runnable/link12010.d        |    2 +-
 gcc/testsuite/gdc.test/runnable/link13394.d        |    2 +-
 gcc/testsuite/gdc.test/runnable/link13400.d        |    2 +-
 gcc/testsuite/gdc.test/runnable/link13415.d        |    2 +-
 gcc/testsuite/gdc.test/runnable/link14588.d        |    2 +-
 gcc/testsuite/gdc.test/runnable/link14814.d        |    2 +-
 gcc/testsuite/gdc.test/runnable/link15017.d        |    2 +-
 gcc/testsuite/gdc.test/runnable/link7745.d         |    2 +-
 gcc/testsuite/gdc.test/runnable/link8023.d         |    2 +-
 gcc/testsuite/gdc.test/runnable/link9571.d         |    2 +-
 gcc/testsuite/gdc.test/runnable/linktypeinfo.d     |    2 +-
 gcc/testsuite/gdc.test/runnable/noreturn1.d        |  152 +
 gcc/testsuite/gdc.test/runnable/test11039.d        |    2 +-
 gcc/testsuite/gdc.test/runnable/test11239.d        |    2 +-
 gcc/testsuite/gdc.test/runnable/test11447a.d       |    2 +-
 gcc/testsuite/gdc.test/runnable/test11447b.d       |    2 +-
 gcc/testsuite/gdc.test/runnable/test11447c.d       |    2 +-
 gcc/testsuite/gdc.test/runnable/test11863.d        |    2 +-
 gcc/testsuite/gdc.test/runnable/test14901.d        |    2 +-
 gcc/testsuite/gdc.test/runnable/test18868.d        |    2 +-
 gcc/testsuite/gdc.test/runnable/test27.d           |    2 +-
 gcc/testsuite/gdc.test/runnable/test29.d           |    2 +-
 gcc/testsuite/gdc.test/runnable/test31.d           |    2 +-
 gcc/testsuite/gdc.test/runnable/test32.d           |    2 +-
 gcc/testsuite/gdc.test/runnable/test38.d           |    2 +-
 gcc/testsuite/gdc.test/runnable/test46.d           |    2 +-
 gcc/testsuite/gdc.test/runnable/test49.d           |    2 +-
 gcc/testsuite/gdc.test/runnable/test57.d           |    2 +-
 gcc/testsuite/gdc.test/runnable/test7494.d         |    2 +-
 gcc/testsuite/gdc.test/runnable/test8997.d         |    2 +-
 gcc/testsuite/gdc.test/runnable/testmod1.d         |    2 +-
 gcc/testsuite/gdc.test/runnable/tls_dup.d          |    2 +-
 gcc/testsuite/gdc.test/runnable_cxx/cppa.d         |    3 +
 libphobos/Makefile.in                              |    2 +-
 libphobos/libdruntime/MERGE                        |    2 +-
 libphobos/libdruntime/Makefile.am                  |    4 +-
 libphobos/libdruntime/Makefile.in                  |    9 +-
 libphobos/libdruntime/__builtins.di                |   40 +
 libphobos/libdruntime/core/demangle.d              |    2 +-
 libphobos/libdruntime/core/int128.d                |  919 +++++
 .../core/internal/gc/impl/conservative/gc.d        |    2 +-
 libphobos/libdruntime/core/lifetime.d              |  373 +-
 libphobos/libdruntime/core/memory.d                |   32 +-
 libphobos/libdruntime/core/stdc/math.d             |   68 +-
 libphobos/libdruntime/core/sys/darwin/dlfcn.d      |   14 -
 .../libdruntime/core/sys/dragonflybsd/dlfcn.d      |   24 -
 libphobos/libdruntime/core/sys/freebsd/dlfcn.d     |   23 -
 libphobos/libdruntime/core/sys/linux/dlfcn.d       |   89 -
 libphobos/libdruntime/core/sys/linux/sys/inotify.d |   16 +-
 libphobos/libdruntime/core/sys/netbsd/dlfcn.d      |   31 -
 libphobos/libdruntime/core/sys/openbsd/dlfcn.d     |    7 -
 libphobos/libdruntime/core/sys/posix/dirent.d      |  240 +-
 libphobos/libdruntime/core/sys/posix/dlfcn.d       |   80 +
 libphobos/libdruntime/core/sys/posix/fcntl.d       |  523 +--
 libphobos/libdruntime/core/sys/posix/poll.d        |  302 +-
 libphobos/libdruntime/core/sys/posix/sched.d       |   61 +-
 libphobos/libdruntime/core/sys/posix/signal.d      | 2003 ++++-------
 libphobos/libdruntime/core/sys/posix/stdc/time.d   |   42 +-
 libphobos/libdruntime/core/sys/posix/stdio.d       |   16 +-
 libphobos/libdruntime/core/sys/posix/sys/ioctl.d   |  366 +-
 libphobos/libdruntime/core/sys/posix/sys/ipc.d     |  116 +-
 libphobos/libdruntime/core/sys/posix/sys/mman.d    |  308 +-
 .../libdruntime/core/sys/posix/sys/resource.d      |  275 +-
 libphobos/libdruntime/core/sys/posix/sys/shm.d     |  166 +-
 libphobos/libdruntime/core/sys/posix/sys/socket.d  |  835 +----
 libphobos/libdruntime/core/sys/posix/sys/stat.d    | 1137 ++-----
 libphobos/libdruntime/core/sys/posix/sys/types.d   |  205 +-
 libphobos/libdruntime/core/sys/posix/sys/wait.d    |  217 +-
 libphobos/libdruntime/core/sys/posix/termios.d     |  281 +-
 libphobos/libdruntime/core/sys/posix/ucontext.d    |  322 +-
 libphobos/libdruntime/core/sys/solaris/dlfcn.d     |   24 -
 libphobos/libdruntime/core/sys/windows/wingdi.d    |    4 +-
 libphobos/libdruntime/core/thread/osthread.d       |   61 -
 libphobos/libdruntime/object.d                     |  383 ++-
 libphobos/libdruntime/rt/dmain2.d                  |    2 +-
 libphobos/libdruntime/rt/util/typeinfo.d           |    5 +-
 libphobos/src/MERGE                                |    2 +-
 libphobos/src/Makefile.am                          |   11 +-
 libphobos/src/Makefile.in                          |   17 +-
 libphobos/src/index.dd                             |    2 +-
 libphobos/src/std/array.d                          |  133 +-
 libphobos/src/std/checkedint.d                     | 3591 ++++++++++++++++++++
 libphobos/src/std/complex.d                        |   22 +-
 libphobos/src/std/conv.d                           |   32 +-
 libphobos/src/std/experimental/allocator/package.d |    8 +-
 libphobos/src/std/experimental/checkedint.d        | 3477 +------------------
 libphobos/src/std/experimental/logger/core.d       |    9 +-
 libphobos/src/std/experimental/logger/filelogger.d |    2 +-
 .../src/std/experimental/logger/multilogger.d      |    2 +-
 libphobos/src/std/file.d                           |  104 +-
 libphobos/src/std/format/package.d                 |    4 +-
 libphobos/src/std/functional.d                     |   59 +-
 libphobos/src/std/json.d                           |    6 +-
 libphobos/src/std/path.d                           |   13 +-
 libphobos/src/std/process.d                        |    5 +-
 libphobos/src/std/range/package.d                  |  286 +-
 libphobos/src/std/regex/package.d                  |   10 +
 libphobos/src/std/stdio.d                          |   26 +-
 libphobos/src/std/traits.d                         |  101 +-
 libphobos/src/std/typecons.d                       |   87 +-
 libphobos/src/std/utf.d                            |   14 +-
 libphobos/src/std/variant.d                        |   58 +-
 libphobos/testsuite/testsuite_flags.in             |    4 +-
 289 files changed, 10838 insertions(+), 10498 deletions(-)

diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc
index 44a0db645dc..73b476666e5 100644
--- a/gcc/d/d-builtins.cc
+++ b/gcc/d/d-builtins.cc
@@ -543,7 +543,7 @@ d_build_builtins_module (Module *m)
 	   flag_unsafe_math_optimizations.
 	 - Built-ins never use the GC or raise a D exception, and so are always
 	   marked as `nothrow' and `@nogc'.  */
-      tf->purity = DECL_PURE_P (decl) ? PURE::strong
+      tf->purity = DECL_PURE_P (decl) ? PURE::const_
 	: TREE_READONLY (decl) ? PURE::const_
 	: DECL_IS_NOVOPS (decl) ? PURE::weak
 	: !DECL_ASSEMBLER_NAME_SET_P (decl) ? PURE::weak
diff --git a/gcc/d/d-gimplify.cc b/gcc/d/d-gimplify.cc
index fbeb60755dd..a98089b7cca 100644
--- a/gcc/d/d-gimplify.cc
+++ b/gcc/d/d-gimplify.cc
@@ -62,6 +62,18 @@ empty_modify_p (tree type, tree op)
   return empty_aggregate_p (type);
 }
 
+/* Return TRUE if EXPR is a COMPONENT_REF to a bit-field declaration.  */
+
+static bool
+bit_field_ref (const_tree expr)
+{
+  if (TREE_CODE (expr) == COMPONENT_REF
+      && DECL_BIT_FIELD (TREE_OPERAND (expr, 1)))
+    return true;
+
+  return false;
+}
+
 /* Gimplify assignment from an INIT_EXPR or MODIFY_EXPR.  */
 
 static gimplify_status
@@ -96,6 +108,13 @@ d_gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
       return GS_OK;
     }
 
+  /* Same as above, but for bit-field assignments.  */
+  if (bit_field_ref (op0) && TREE_TYPE (op0) != TREE_TYPE (op1))
+    {
+      TREE_OPERAND (*expr_p, 1) = convert (TREE_TYPE (op0), op1);
+      return GS_OK;
+    }
+
   return GS_UNHANDLED;
 }
 
@@ -178,6 +197,54 @@ d_gimplify_unsigned_rshift_expr (tree *expr_p)
   return GS_OK;
 }
 
+/* Gimplify an unary expression node.  */
+
+static gimplify_status
+d_gimplify_unary_expr (tree *expr_p)
+{
+  tree op0 = TREE_OPERAND (*expr_p, 0);
+
+  if (error_operand_p (op0))
+    return GS_UNHANDLED;
+
+  /* Front end doesn't know that bit-field types are really different
+     from basic types, add an explicit conversion in unary expressions.  */
+  if (bit_field_ref (op0) && TREE_TYPE (op0) != TREE_TYPE (*expr_p))
+    {
+      TREE_OPERAND (*expr_p, 0) = convert (TREE_TYPE (*expr_p), op0);
+      return GS_OK;
+    }
+
+  return GS_UNHANDLED;
+}
+
+/* Gimplify a binary expression node.  */
+
+static gimplify_status
+d_gimplify_binary_expr (tree *expr_p)
+{
+  tree op0 = TREE_OPERAND (*expr_p, 0);
+  tree op1 = TREE_OPERAND (*expr_p, 1);
+
+  if (error_operand_p (op0) || error_operand_p (op1))
+    return GS_UNHANDLED;
+
+  /* Front end doesn't know that bit-field types are really different
+     from basic types, add an explicit conversion in binary expressions.  */
+  if (bit_field_ref (op0) || bit_field_ref (op1))
+    {
+      if (TREE_TYPE (op0) != TREE_TYPE (*expr_p))
+    	TREE_OPERAND (*expr_p, 0) = convert (TREE_TYPE (*expr_p), op0);
+
+      if (TREE_TYPE (op1) != TREE_TYPE (*expr_p))
+    	TREE_OPERAND (*expr_p, 1) = convert (TREE_TYPE (*expr_p), op1);
+
+      return GS_OK;
+    }
+
+  return GS_UNHANDLED;
+}
+
 /* Implements the lang_hooks.gimplify_expr routine for language D.
    Do gimplification of D specific expression trees in EXPR_P.  */
 
@@ -203,6 +270,10 @@ d_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
       gcc_unreachable ();
 
     default:
+      if (UNARY_CLASS_P (*expr_p) && !CONVERT_EXPR_P (*expr_p))
+	return d_gimplify_unary_expr (expr_p);
+      if (BINARY_CLASS_P (*expr_p))
+	return d_gimplify_binary_expr (expr_p);
       break;
     }
 
diff --git a/gcc/d/d-target.cc b/gcc/d/d-target.cc
index 87cb48f6680..02f7b742455 100644
--- a/gcc/d/d-target.cc
+++ b/gcc/d/d-target.cc
@@ -161,6 +161,8 @@ Target::_init (const Param &)
   this->c.longsize = int_size_in_bytes (long_integer_type_node);
   this->c.long_doublesize = int_size_in_bytes (long_double_type_node);
   this->c.wchar_tsize = (WCHAR_TYPE_SIZE / BITS_PER_UNIT);
+  this->c.bitFieldStyle = targetm.ms_bitfield_layout_p (unknown_type_node)
+    ? TargetC::BitFieldStyle::MS : TargetC::BitFieldStyle::Gcc_Clang;
 
   /* Set-up target C++ ABI.  */
   this->cpp.reverseOverloads = false;
@@ -379,32 +381,21 @@ TargetCPP::typeMangle (Type *type)
    ARG to an extern(C++) function.  */
 
 Type *
-TargetCPP::parameterType (Parameter *arg)
+TargetCPP::parameterType (Type *type)
 {
-  Type *t = arg->type->merge2 ();
-  if (arg->storageClass & (STCout | STCref))
-    t = t->referenceTo ();
-  else if (arg->storageClass & STClazy)
-    {
-      /* Mangle as delegate.  */
-      TypeFunction *tf = TypeFunction::create (NULL, t, VARARGnone, LINK::d);
-      TypeDelegate *td = TypeDelegate::create (tf);
-      t = td->merge2 ();
-    }
-
   /* Could be a va_list, which we mangle as a pointer.  */
   Type *tvalist = target.va_listType (Loc (), NULL);
-  if (t->ty == TY::Tsarray && tvalist->ty == TY::Tsarray)
+  if (type->ty == TY::Tsarray && tvalist->ty == TY::Tsarray)
     {
-      Type *tb = t->toBasetype ()->mutableOf ();
+      Type *tb = type->toBasetype ()->mutableOf ();
       if (tb == tvalist)
 	{
-	  tb = t->nextOf ()->pointerTo ();
-	  t = tb->castMod (t->mod);
+	  tb = type->nextOf ()->pointerTo ();
+	  type = tb->castMod (type->mod);
 	}
     }
 
-  return t;
+  return type;
 }
 
 /* Checks whether TYPE is a vendor-specific fundamental type.  Stores the result
@@ -579,6 +570,14 @@ Target::libraryObjectMonitors (FuncDeclaration *, Statement *)
   return true;
 }
 
+/* Returns true if the target supports `pragma(linkerDirective)'.  */
+
+bool
+Target::supportsLinkerDirective (void) const
+{
+  return false;
+}
+
 /* Decides whether an `in' parameter of the specified POD type PARAM_TYPE is to
    be passed by reference or by valie.  This is used only when compiling with
    `-fpreview=in' enabled.  */
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 5915706af11..91cdc9f0692 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-001bfd97b0e75423970260dac54f453be9b57f4c
+52844d4b1e9d6714bfd2e535f25a72074a046209
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/README.md b/gcc/d/dmd/README.md
index 6b91e22e3e5..f613ab28577 100644
--- a/gcc/d/dmd/README.md
+++ b/gcc/d/dmd/README.md
@@ -33,6 +33,7 @@ Note that these groups have no strict meaning, the category assignments are a bi
 |-----------------------------------------------------------------------------|-----------------------------------------------------------------------|
 | [mars.d](https://github.com/dlang/dmd/blob/master/src/dmd/mars.d)           | The entry point. Contains `main`.                                     |
 | [cli.d](https://github.com/dlang/dmd/blob/master/src/dmd/cli.d)             | Define the command line interface                                     |
+| [dmdparams.d](https://github.com/dlang/dmd/blob/master/src/dmd/dmdparams.d) | DMD-specific parameters                                               |
 | [globals.d](https://github.com/dlang/dmd/blob/master/src/dmd/globals.d)     | Define a structure storing command line options                       |
 | [dinifile.d](https://github.com/dlang/dmd/blob/master/src/dmd/dinifile.d)   | Parse settings from .ini file (`sc.ini` / `dmd.conf`)                 |
 | [vsoptions.d](https://github.com/dlang/dmd/blob/master/src/dmd/vsoptions.d) | Detect the Microsoft Visual Studio toolchain for linking              |
diff --git a/gcc/d/dmd/access.d b/gcc/d/dmd/access.d
index 51ef049f860..59c77adf45c 100644
--- a/gcc/d/dmd/access.d
+++ b/gcc/d/dmd/access.d
@@ -51,15 +51,7 @@ bool checkAccess(AggregateDeclaration ad, Loc loc, Scope* sc, Dsymbol smember)
 
     if (!symbolIsVisible(sc, smember))
     {
-        // when in @safe code or with -preview=dip1000
-        if (sc.flags & SCOPE.onlysafeaccess)
-        {
-            // if there is a func. ask for it's opinion of safety, and if it considers the access @safe accept it.
-            if (sc.func && !sc.func.setUnsafe())
-                return false;
-        }
-
-        ad.error(loc, "%s `%s` is not accessible%s", smember.kind(), smember.toChars(), (sc.flags & SCOPE.onlysafeaccess) ? " from `@safe` code".ptr : "".ptr);
+        ad.error(loc, "%s `%s` is not accessible", smember.kind(), smember.toChars());
         //printf("smember = %s %s, vis = %d, semanticRun = %d\n",
         //        smember.kind(), smember.toPrettyChars(), smember.visible() smember.semanticRun);
         return true;
diff --git a/gcc/d/dmd/astenums.d b/gcc/d/dmd/astenums.d
index 3e86cfa130e..ea10c4e9c40 100644
--- a/gcc/d/dmd/astenums.d
+++ b/gcc/d/dmd/astenums.d
@@ -134,6 +134,8 @@ enum STC : ulong  // transfer changes to declaration.h
 
 }
 
+alias StorageClass = ulong;
+
 /********
  * Determine if it's the ambigous case of where `return` attaches to.
  * Params:
@@ -302,8 +304,7 @@ enum PURE : ubyte
     impure      = 0,    // not pure at all
     fwdref      = 1,    // it's pure, but not known which level yet
     weak        = 2,    // no mutable globals are read or written
-    const_      = 3,    // parameters are values or const
-    strong      = 4,    // parameters are values or immutable
+    const_      = 3,    // parameters are values or const = strongly pure
 }
 
 // Whether alias this dependency is recursive or not
@@ -389,3 +390,43 @@ enum InitKind : ubyte
     C_,
 }
 
+/// A linkage attribute as defined by `extern(XXX)`
+///
+/// https://dlang.org/spec/attribute.html#linkage
+enum LINK : ubyte
+{
+    default_,
+    d,
+    c,
+    cpp,
+    windows,
+    objc,
+    system,
+}
+
+/// Whether to mangle an external aggregate as a struct or class, as set by `extern(C++, struct)`
+enum CPPMANGLE : ubyte
+{
+    def,      /// default
+    asStruct, /// `extern(C++, struct)`
+    asClass,  /// `extern(C++, class)`
+}
+
+/// Function match levels
+///
+/// https://dlang.org/spec/function.html#function-overloading
+enum MATCH : int
+{
+    nomatch,   /// no match
+    convert,   /// match with conversions
+    constant,  /// match with conversion to const
+    exact,     /// exact match
+}
+
+/// Inline setting as defined by `pragma(inline, XXX)`
+enum PINLINE : ubyte
+{
+    default_, /// as specified on the command line
+    never,    /// never inline
+    always,   /// always inline
+}
diff --git a/gcc/d/dmd/attrib.d b/gcc/d/dmd/attrib.d
index 5d44760caad..cf9e9ce5a22 100644
--- a/gcc/d/dmd/attrib.d
+++ b/gcc/d/dmd/attrib.d
@@ -43,6 +43,7 @@ import dmd.identifier;
 import dmd.mtype;
 import dmd.objc; // for objc.addSymbols
 import dmd.common.outbuffer;
+import dmd.root.array; // for each
 import dmd.target; // for target.systemLinkage
 import dmd.tokens;
 import dmd.visitor;
@@ -1519,3 +1520,60 @@ extern (C++) final class UserAttributeDeclaration : AttribDeclaration
         }
     }
 }
+
+/**
+ * Returns `true` if the given symbol is a symbol declared in
+ * `core.attribute` and has the given identifier.
+ *
+ * This is used to determine if a symbol is a UDA declared in
+ * `core.attribute`.
+ *
+ * Params:
+ *  sym = the symbol to check
+ *  ident = the name of the expected UDA
+ */
+bool isCoreUda(Dsymbol sym, Identifier ident)
+{
+    if (sym.ident != ident || !sym.parent)
+        return false;
+
+    auto _module = sym.parent.isModule();
+    return _module && _module.isCoreModule(Id.attribute);
+}
+
+/**
+ * Iterates the UDAs attached to the given symbol.
+ *
+ * If `dg` returns `!= 0`, it will stop the iteration and return that
+ * value, otherwise it will return 0.
+ *
+ * Params:
+ *  sym = the symbol to get the UDAs from
+ *  sc = scope to use for semantic analysis of UDAs
+ *  dg = called once for each UDA. If `dg` returns `!= 0`, it will stop the
+ *      iteration and return that value, otherwise it will return `0`.
+ */
+int foreachUda(Dsymbol sym, Scope* sc, int delegate(Expression) dg)
+{
+    if (!sym.userAttribDecl)
+        return 0;
+
+    auto udas = sym.userAttribDecl.getAttributes();
+    arrayExpressionSemantic(udas, sc, true);
+
+    return udas.each!((uda) {
+        if (!uda.isTupleExp())
+            return 0;
+
+        auto exps = uda.isTupleExp().exps;
+
+        return exps.each!((e) {
+            assert(e);
+
+            if (auto result = dg(e))
+                return result;
+
+            return 0;
+        });
+    });
+}
diff --git a/gcc/d/dmd/blockexit.d b/gcc/d/dmd/blockexit.d
index c4a95777e03..5132a2dc46a 100644
--- a/gcc/d/dmd/blockexit.d
+++ b/gcc/d/dmd/blockexit.d
@@ -110,8 +110,8 @@ int blockExit(Statement s, FuncDeclaration func, bool mustNotThrow)
                 }
                 if (s.exp.type && s.exp.type.toBasetype().isTypeNoreturn())
                     result = BE.halt;
-                if (canThrow(s.exp, func, mustNotThrow))
-                    result |= BE.throw_;
+
+                result |= canThrow(s.exp, func, mustNotThrow);
             }
         }
 
@@ -149,7 +149,7 @@ int blockExit(Statement s, FuncDeclaration func, bool mustNotThrow)
                             else if (!func.getModule().isCFile)
                             {
                                 const(char)* gototype = s.isCaseStatement() ? "case" : "default";
-                                s.deprecation("switch case fallthrough - use 'goto %s;' if intended", gototype);
+                                s.error("switch case fallthrough - use 'goto %s;' if intended", gototype);
                             }
                         }
                     }
@@ -214,8 +214,8 @@ int blockExit(Statement s, FuncDeclaration func, bool mustNotThrow)
                 result = BE.fallthru;
             if (result & BE.fallthru)
             {
-                if (canThrow(s.condition, func, mustNotThrow))
-                    result |= BE.throw_;
+                result |= canThrow(s.condition, func, mustNotThrow);
+
                 if (!(result & BE.break_) && s.condition.toBool().hasValue(true))
                     result &= ~BE.fallthru;
             }
@@ -233,8 +233,8 @@ int blockExit(Statement s, FuncDeclaration func, bool mustNotThrow)
             }
             if (s.condition)
             {
-                if (canThrow(s.condition, func, mustNotThrow))
-                    result |= BE.throw_;
+                result |= canThrow(s.condition, func, mustNotThrow);
+
                 const opt = s.condition.toBool();
                 if (opt.hasValue(true))
                     result &= ~BE.fallthru;
@@ -250,15 +250,15 @@ int blockExit(Statement s, FuncDeclaration func, bool mustNotThrow)
                     result |= BE.fallthru;
                 result |= r & ~(BE.fallthru | BE.break_ | BE.continue_);
             }
-            if (s.increment && canThrow(s.increment, func, mustNotThrow))
-                result |= BE.throw_;
+            if (s.increment)
+                result |= canThrow(s.increment, func, mustNotThrow);
         }
 
         override void visit(ForeachStatement s)
         {
             result = BE.fallthru;
-            if (canThrow(s.aggr, func, mustNotThrow))
-                result |= BE.throw_;
+            result |= canThrow(s.aggr, func, mustNotThrow);
+
             if (s._body)
                 result |= blockExit(s._body, func, mustNotThrow) & ~(BE.break_ | BE.continue_);
         }
@@ -273,8 +273,7 @@ int blockExit(Statement s, FuncDeclaration func, bool mustNotThrow)
         {
             //printf("IfStatement::blockExit(%p)\n", s);
             result = BE.none;
-            if (canThrow(s.condition, func, mustNotThrow))
-                result |= BE.throw_;
+            result |= canThrow(s.condition, func, mustNotThrow);
 
             const opt = s.condition.toBool();
             if (opt.hasValue(true))
@@ -313,8 +312,8 @@ int blockExit(Statement s, FuncDeclaration func, bool mustNotThrow)
         override void visit(SwitchStatement s)
         {
             result = BE.none;
-            if (canThrow(s.condition, func, mustNotThrow))
-                result |= BE.throw_;
+            result |= canThrow(s.condition, func, mustNotThrow);
+
             if (s._body)
             {
                 result |= blockExit(s._body, func, mustNotThrow);
@@ -357,8 +356,8 @@ int blockExit(Statement s, FuncDeclaration func, bool mustNotThrow)
         override void visit(ReturnStatement s)
         {
             result = BE.return_;
-            if (s.exp && canThrow(s.exp, func, mustNotThrow))
-                result |= BE.throw_;
+            if (s.exp)
+                result |= canThrow(s.exp, func, mustNotThrow);
         }
 
         override void visit(BreakStatement s)
@@ -380,8 +379,7 @@ int blockExit(Statement s, FuncDeclaration func, bool mustNotThrow)
         override void visit(WithStatement s)
         {
             result = BE.none;
-            if (canThrow(s.exp, func, mustNotThrow))
-                result = BE.throw_;
+            result |= canThrow(s.exp, func, mustNotThrow);
             result |= blockExit(s._body, func, mustNotThrow);
         }
 
@@ -483,19 +481,7 @@ int blockExit(Statement s, FuncDeclaration func, bool mustNotThrow)
                 return;
             }
 
-            Type t = s.exp.type.toBasetype();
-            ClassDeclaration cd = t.isClassHandle();
-            assert(cd);
-
-            if (cd == ClassDeclaration.errorException || ClassDeclaration.errorException.isBaseOf(cd, null))
-            {
-                result = BE.errthrow;
-                return;
-            }
-            if (mustNotThrow)
-                s.error("`%s` is thrown but not caught", s.exp.type.toChars());
-
-            result = BE.throw_;
+            result = checkThrow(s.loc, s.exp, mustNotThrow);
         }
 
         override void visit(GotoStatement s)
@@ -537,3 +523,32 @@ int blockExit(Statement s, FuncDeclaration func, bool mustNotThrow)
     s.accept(be);
     return be.result;
 }
+
+/++
+ + Checks whether `throw <exp>` throws an `Exception` or an `Error`
+ + and raises an error if this violates `nothrow`.
+ +
+ + Params:
+ +   loc          = location of the `throw`
+ +   exp          = expression yielding the throwable
+ +   mustNotThrow = inside of a `nothrow` scope?
+ +
+ + Returns: `BE.[err]throw` depending on the type of `exp`
+ +/
+BE checkThrow(ref const Loc loc, Expression exp, const bool mustNotThrow)
+{
+    import dmd.errors : error;
+
+    Type t = exp.type.toBasetype();
+    ClassDeclaration cd = t.isClassHandle();
+    assert(cd);
+
+    if (cd == ClassDeclaration.errorException || ClassDeclaration.errorException.isBaseOf(cd, null))
+    {
+        return BE.errthrow;
+    }
+    if (mustNotThrow)
+        loc.error("`%s` is thrown but not caught", exp.type.toChars());
+
+    return BE.throw_;
+}
diff --git a/gcc/d/dmd/canthrow.d b/gcc/d/dmd/canthrow.d
index e6eb0ace2ee..faf427d6735 100644
--- a/gcc/d/dmd/canthrow.d
+++ b/gcc/d/dmd/canthrow.d
@@ -18,6 +18,7 @@ import dmd.apply;
 import dmd.arraytypes;
 import dmd.attrib;
 import dmd.astenums;
+import dmd.blockexit : BE, checkThrow;
 import dmd.declaration;
 import dmd.dsymbol;
 import dmd.expression;
@@ -29,11 +30,28 @@ import dmd.root.rootobject;
 import dmd.tokens;
 import dmd.visitor;
 
+/**
+ * Status indicating what kind of throwable might be caused by an expression.
+ *
+ * This is a subset of `BE` restricted to the values actually used by `canThrow`.
+ */
+enum CT : BE
+{
+    /// Never throws an `Exception` or `Throwable`
+    none = BE.none,
+
+    /// Might throw an `Exception`
+    exception = BE.throw_,
+
+    // Might throw an `Error`
+    error = BE.errthrow,
+}
+
 /********************************************
  * Returns true if the expression may throw exceptions.
  * If 'mustNotThrow' is true, generate an error if it throws
  */
-extern (C++) bool canThrow(Expression e, FuncDeclaration func, bool mustNotThrow)
+extern (C++) /* CT */ BE canThrow(Expression e, FuncDeclaration func, bool mustNotThrow)
 {
     //printf("Expression::canThrow(%d) %s\n", mustNotThrow, toChars());
     // stop walking if we determine this expression can throw
@@ -42,6 +60,7 @@ extern (C++) bool canThrow(Expression e, FuncDeclaration func, bool mustNotThrow
         alias visit = typeof(super).visit;
         FuncDeclaration func;
         bool mustNotThrow;
+        CT result;
 
     public:
         extern (D) this(FuncDeclaration func, bool mustNotThrow)
@@ -62,7 +81,7 @@ extern (C++) bool canThrow(Expression e, FuncDeclaration func, bool mustNotThrow
 
                     e.checkOverridenDtor(null, f, dd => dd.type.toTypeFunction().isnothrow, "not nothrow");
                 }
-                stop = true;  // if any function throws, then the whole expression throws
+                result |= CT.exception;
             }
         }
 
@@ -72,7 +91,7 @@ extern (C++) bool canThrow(Expression e, FuncDeclaration func, bool mustNotThrow
 
         override void visit(DeclarationExp de)
         {
-            stop = Dsymbol_canThrow(de.declaration, func, mustNotThrow);
+            result |= Dsymbol_canThrow(de.declaration, func, mustNotThrow);
         }
 
         override void visit(CallExp ce)
@@ -83,18 +102,27 @@ extern (C++) bool canThrow(Expression e, FuncDeclaration func, bool mustNotThrow
             if (global.errors && !ce.e1.type)
                 return; // error recovery
 
-            import dmd.id : Id;
-
-            if (ce.f && ce.f.ident == Id._d_delstruct)
+            if (ce.f && ce.arguments.dim > 0)
             {
-                // Only check if the dtor throws.
                 Type tb = (*ce.arguments)[0].type.toBasetype();
-                auto ts = tb.nextOf().baseElemOf().isTypeStruct();
-                if (ts)
+                auto tbNext = tb.nextOf();
+                if (tbNext)
                 {
-                    auto sd = ts.sym;
-                    if (sd.dtor)
-                        checkFuncThrows(ce, sd.dtor);
+                    auto ts = tbNext.baseElemOf().isTypeStruct();
+                    if (ts)
+                    {
+                        import dmd.id : Id;
+
+                        auto sd = ts.sym;
+                        if (sd.dtor && ce.f.ident == Id._d_delstruct)
+                            checkFuncThrows(ce, sd.dtor);
+                        else if (sd.postblit &&
+                            (ce.f.ident == Id._d_arrayctor || ce.f.ident == Id._d_arraysetctor))
+                        {
+                            checkFuncThrows(ce, sd.postblit);
+                            return;
+                        }
+                    }
                 }
             }
 
@@ -124,7 +152,7 @@ extern (C++) bool canThrow(Expression e, FuncDeclaration func, bool mustNotThrow
                     e1 = pe.e1;
                 ce.error("`%s` is not `nothrow`", e1.toChars());
             }
-            stop = true;
+            result |= CT.exception;
         }
 
         override void visit(NewExp ne)
@@ -187,6 +215,13 @@ extern (C++) bool canThrow(Expression e, FuncDeclaration func, bool mustNotThrow
                     checkFuncThrows(ae, postblit);
         }
 
+        override void visit(ThrowExp te)
+        {
+            const res = checkThrow(te.loc, te.e1, mustNotThrow);
+            assert((res & ~(CT.exception | CT.error)) == 0);
+            result |= res;
+        }
+
         override void visit(NewAnonClassExp)
         {
             assert(0); // should have been lowered by semantic()
@@ -194,18 +229,22 @@ extern (C++) bool canThrow(Expression e, FuncDeclaration func, bool mustNotThrow
     }
 
     scope CanThrow ct = new CanThrow(func, mustNotThrow);
-    return walkPostorder(e, ct);
+    walkPostorder(e, ct);
+    return ct.result;
 }
 
 /**************************************
  * Does symbol, when initialized, throw?
  * Mirrors logic in Dsymbol_toElem().
  */
-private bool Dsymbol_canThrow(Dsymbol s, FuncDeclaration func, bool mustNotThrow)
+private CT Dsymbol_canThrow(Dsymbol s, FuncDeclaration func, bool mustNotThrow)
 {
+    CT result;
+
     int symbolDg(Dsymbol s)
     {
-        return Dsymbol_canThrow(s, func, mustNotThrow);
+        result |= Dsymbol_canThrow(s, func, mustNotThrow);
+        return 0;
     }
 
     //printf("Dsymbol_toElem() %s\n", s.toChars());
@@ -225,20 +264,19 @@ private bool Dsymbol_canThrow(Dsymbol s, FuncDeclaration func, bool mustNotThrow
             if (vd._init)
             {
                 if (auto ie = vd._init.isExpInitializer())
-                    if (canThrow(ie.exp, func, mustNotThrow))
-                        return true;
+                    result |= canThrow(ie.exp, func, mustNotThrow);
             }
             if (vd.needsScopeDtor())
-                return canThrow(vd.edtor, func, mustNotThrow);
+                result |= canThrow(vd.edtor, func, mustNotThrow);
         }
     }
     else if (auto ad = s.isAttribDeclaration())
     {
-        return ad.include(null).foreachDsymbol(&symbolDg) != 0;
+        ad.include(null).foreachDsymbol(&symbolDg);
     }
     else if (auto tm = s.isTemplateMixin())
     {
-        return tm.members.foreachDsymbol(&symbolDg) != 0;
+        tm.members.foreachDsymbol(&symbolDg);
     }
     else if (auto td = s.isTupleDeclaration())
     {
@@ -250,11 +288,10 @@ private bool Dsymbol_canThrow(Dsymbol s, FuncDeclaration func, bool mustNotThrow
                 Expression eo = cast(Expression)o;
                 if (auto se = eo.isDsymbolExp())
                 {
-                    if (Dsymbol_canThrow(se.s, func, mustNotThrow))
-                        return true;
+                    result |= Dsymbol_canThrow(se.s, func, mustNotThrow);
                 }
             }
         }
     }
-    return false;
+    return result;
 }
diff --git a/gcc/d/dmd/constfold.d b/gcc/d/dmd/constfold.d
index 76e1d7fbaf2..16f7b2f4019 100644
--- a/gcc/d/dmd/constfold.d
+++ b/gcc/d/dmd/constfold.d
@@ -120,18 +120,13 @@ UnionExp Not(Type type, Expression e1)
 {
     UnionExp ue = void;
     Loc loc = e1.loc;
+    // BUG: Should be replaced with e1.toBool().get(), but this is apparently
+    //      executed for some expressions that cannot be const-folded
+    //      To be fixed in another PR
     emplaceExp!(IntegerExp)(&ue, loc, e1.toBool().hasValue(false) ? 1 : 0, type);
     return ue;
 }
 
-private UnionExp Bool(Type type, Expression e1)
-{
-    UnionExp ue = void;
-    Loc loc = e1.loc;
-    emplaceExp!(IntegerExp)(&ue, loc, e1.toBool().hasValue(true) ? 1 : 0, type);
-    return ue;
-}
-
 UnionExp Add(const ref Loc loc, Type type, Expression e1, Expression e2)
 {
     UnionExp ue = void;
@@ -1093,19 +1088,14 @@ UnionExp Cast(const ref Loc loc, Type type, Type to, Expression e1)
     }
     else if (tb.ty == Tbool)
     {
-        bool val = void;
         const opt = e1.toBool();
-        if (opt.hasValue(true))
-            val = true;
-        else if (opt.hasValue(false))
-            val = false;
-        else
+        if (opt.isEmpty())
         {
             cantExp(ue);
             return ue;
         }
 
-        emplaceExp!(IntegerExp)(&ue, loc, val, type);
+        emplaceExp!(IntegerExp)(&ue, loc, opt.get(), type);
     }
     else if (type.isintegral())
     {
diff --git a/gcc/d/dmd/cparse.d b/gcc/d/dmd/cparse.d
index 8d3f3b33ead..38a78a0b013 100644
--- a/gcc/d/dmd/cparse.d
+++ b/gcc/d/dmd/cparse.d
@@ -35,7 +35,8 @@ final class CParser(AST) : Parser!AST
 {
     AST.Dsymbols* symbols;      // symbols declared in current scope
 
-    bool addFuncName;             /// add declaration of __func__ to function symbol table
+    bool addFuncName;           /// add declaration of __func__ to function symbol table
+    bool importBuiltins;        /// seen use of C compiler builtins, so import __builtins;
 
     extern (D) this(TARGET)(AST.Module _module, const(char)[] input, bool doDocComment,
                             const ref TARGET target)
@@ -72,7 +73,6 @@ final class CParser(AST) : Parser!AST
     {
         //printf("cparseTranslationUnit()\n");
         symbols = new AST.Dsymbols();
-        addBuiltinDeclarations();
         while (1)
         {
             if (token.value == TOK.endOfFile)
@@ -82,6 +82,15 @@ final class CParser(AST) : Parser!AST
                 auto ld = new AST.LinkDeclaration(token.loc, LINK.c, symbols);
                 wrap.push(ld);
 
+                if (importBuiltins)
+                {
+                    /* Seen references to C builtin functions.
+                     * Import their definitions
+                     */
+                    auto s = new AST.Import(Loc.initial, null, Id.builtins, null, false);
+                    wrap.push(s);
+                }
+
                 return wrap;
             }
 
@@ -596,6 +605,7 @@ final class CParser(AST) : Parser!AST
      *    string-literal
      *    ( expression )
      *    generic-selection
+     *    __builtin_va_arg(assign_expression, type)
      */
     AST.Expression cparsePrimaryExp()
     {
@@ -606,9 +616,20 @@ final class CParser(AST) : Parser!AST
         switch (token.value)
         {
         case TOK.identifier:
-            if (token.ident is Id.__func__)
+            const id = token.ident.toString();
+            if (id.length > 2 && id[0] == '_' && id[1] == '_')  // leading double underscore
             {
-                addFuncName = true;     // implicitly declare __func__
+                if (token.ident is Id.__func__)
+                {
+                    addFuncName = true;     // implicitly declare __func__
+                }
+                else if (token.ident is Id.builtin_va_arg)
+                {
+                    e = cparseBuiltin_va_arg();
+                    break;
+                }
+                else
+                    importBuiltins = true;  // probably one of those compiler extensions
             }
             e = new AST.IdentifierExp(loc, token.ident);
             nextToken();
@@ -1449,6 +1470,40 @@ final class CParser(AST) : Parser!AST
         return cparseAssignExp();
     }
 
+    /*****************************
+     * gcc extension:
+     *    type __builtin_va_arg(assign-expression, type)
+     * Rewrite as `va_arg` template from `core.stdc.stdarg`:
+     *    va_arg!(type)(assign-expression);
+     * Lexer is on `__builtin_va_arg`
+     */
+    private AST.Expression cparseBuiltin_va_arg()
+    {
+        importBuiltins = true;  // need core.stdc.stdarg
+
+        nextToken();
+        check(TOK.leftParenthesis);
+
+        auto arguments = new AST.Expressions();
+        auto arg = cparseAssignExp();
+        arguments.push(arg);
+
+        check(TOK.comma);
+
+        auto t = cparseTypeName();
+        auto tiargs = new AST.Objects();
+        tiargs.push(t);
+
+        const loc = loc;
+        auto ti = new AST.TemplateInstance(loc, Id.va_arg, tiargs);
+        auto tie = new AST.ScopeExp(loc, ti);
+
+        AST.Expression e = new AST.CallExp(loc, tie, arguments);
+
+        check(TOK.rightParenthesis);
+        return e;
+    }
+
     //}
     /********************************************************************************/
     /********************************* Declaration Parser ***************************/
@@ -1481,6 +1536,14 @@ final class CParser(AST) : Parser!AST
             return;
         }
 
+        if (token.value == TOK._import) // import declaration extension
+        {
+            auto a = parseImport();
+            if (a && a.length)
+                symbols.append(a);
+            return;
+        }
+
         auto symbolsSave = symbols;
         Specifier specifier;
         specifier.packalign = this.packalign;
@@ -1504,7 +1567,7 @@ final class CParser(AST) : Parser!AST
              */
             auto stag = (tt.tok == TOK.struct_) ? new AST.StructDeclaration(tt.loc, tt.id, false) :
                         (tt.tok == TOK.union_)  ? new AST.UnionDeclaration(tt.loc, tt.id) :
-                                                  new AST.EnumDeclaration(tt.loc, tt.id, AST.Type.tint32);
+                                                  new AST.EnumDeclaration(tt.loc, tt.id, tt.base);
             stag.members = tt.members;
             if (!symbols)
                 symbols = new AST.Dsymbols();
@@ -1550,26 +1613,18 @@ final class CParser(AST) : Parser!AST
                 case TOK.semicolon:
                 case TOK.asm_:
                 case TOK.__attribute__:
-                    /* This is a data definition, there cannot now be a
-                     * function definition.
-                     */
-                    first = false;
                     if (token.value == TOK.asm_)
                         asmname = cparseSimpleAsmExpr();
                     if (token.value == TOK.__attribute__)
                     {
                         cparseGnuAttributes(specifier);
                         if (token.value == TOK.leftCurly)
-                        {
-                            error("attributes should be specified before the function definition");
-                            auto t = &token;
-                            if (skipBraces(t))
-                            {
-                                token = *t;
-                                return;
-                            }
-                        }
+                            break;              // function definition
                     }
+                    /* This is a data definition, there cannot now be a
+                     * function definition.
+                     */
+                    first = false;
                     break;
 
                 default:
@@ -1636,6 +1691,30 @@ final class CParser(AST) : Parser!AST
                         isalias = false;
                     }
                 }
+                else if (auto tt = dt.isTypeTag())
+                {
+                    if (tt.id || tt.tok == TOK.enum_)
+                    {
+                        /* `struct tag;` and `struct tag { ... };`
+                         * always result in a declaration in the current scope
+                         */
+                        auto stag = (tt.tok == TOK.struct_) ? new AST.StructDeclaration(tt.loc, tt.id, false) :
+                                    (tt.tok == TOK.union_)  ? new AST.UnionDeclaration(tt.loc, tt.id) :
+                                                              new AST.EnumDeclaration(tt.loc, tt.id, tt.base);
+                        stag.members = tt.members;
+                        tt.members = null;
+                        if (!symbols)
+                            symbols = new AST.Dsymbols();
+                        symbols.push(stag);
+                        if (tt.tok == TOK.enum_)
+                        {
+                            if (!tt.members)
+                                error(tt.loc, "`enum %s` has no members", stag.toChars());
+                            isalias = false;
+                            s = new AST.AliasDeclaration(token.loc, id, stag);
+                        }
+                    }
+                }
                 if (isalias)
                     s = new AST.AliasDeclaration(token.loc, id, dt);
             }
@@ -1768,6 +1847,7 @@ final class CParser(AST) : Parser!AST
             if (pl.varargs != AST.VarArg.none && pl.length)
                 error("function identifier-list cannot end with `...`");
             ft.parameterList.varargs = AST.VarArg.variadic;     // but C11 allows extra arguments
+            importBuiltins = true;                              // will need __va_list_tag
             auto plLength = pl.length;
             if (symbols.length != plLength)
                 error("%d identifiers does not match %d declarations", cast(int)plLength, cast(int)symbols.length);
@@ -2230,8 +2310,14 @@ final class CParser(AST) : Parser!AST
             case TKW.xcomplex | TKW.xdouble:               t = AST.Type.tcomplex64; break;
             case TKW.xcomplex | TKW.xlong | TKW.xdouble:   t = realType(RTFlags.complex); break;
 
-            case TKW.xident:                    t = new AST.TypeIdentifier(loc, previd);
+            case TKW.xident:
+            {
+                const idx = previd.toString();
+                if (idx.length > 2 && idx[0] == '_' && idx[1] == '_')  // leading double underscore
+                    importBuiltins = true;  // probably one of those compiler extensions
+                t = new AST.TypeIdentifier(loc, previd);
                 break;
+            }
 
             case TKW.xtag:
                 break;          // t is already set
@@ -2599,6 +2685,7 @@ final class CParser(AST) : Parser!AST
         if (token.value == TOK.rightParenthesis)        // func()
         {
             nextToken();
+            importBuiltins = true;                              // will need __va_list_tag
             return AST.ParameterList(parameters, AST.VarArg.variadic, varargsStc);
         }
 
@@ -2613,6 +2700,7 @@ final class CParser(AST) : Parser!AST
             {
                 if (parameters.length == 0)     // func(...)
                     error("named parameter required before `...`");
+                importBuiltins = true;          // will need __va_list_tag
                 varargs = AST.VarArg.variadic;  // C-style variadics
                 nextToken();
                 check(TOK.rightParenthesis);
@@ -3011,6 +3099,17 @@ final class CParser(AST) : Parser!AST
             nextToken();
         }
 
+        /* clang extension: add optional base type after the identifier
+         * https://en.cppreference.com/w/cpp/language/enum
+         *   enum Identifier : Type
+         */
+        AST.Type base = AST.Type.tint32;  // C11 6.7.2.2-4 implementation defined default base type
+        if (token.value == TOK.colon)
+        {
+            nextToken();
+            base = cparseTypeName();
+        }
+
         AST.Dsymbols* members;
         if (token.value == TOK.leftCurly)
         {
@@ -3084,7 +3183,7 @@ final class CParser(AST) : Parser!AST
          * redeclaration, or reference to existing declaration.
          * Defer to the semantic() pass with a TypeTag.
          */
-        return new AST.TypeTag(loc, TOK.enum_, tag, members);
+        return new AST.TypeTag(loc, TOK.enum_, tag, base, members);
     }
 
     /*************************************
@@ -3124,17 +3223,14 @@ final class CParser(AST) : Parser!AST
         if (token.value == TOK.leftCurly)
         {
             nextToken();
-            auto symbolsSave = symbols;
-            symbols = new AST.Dsymbols();
+            members = new AST.Dsymbols();          // so `members` will be non-null even with 0 members
             while (token.value != TOK.rightCurly)
             {
-                cparseStructDeclaration();
+                cparseStructDeclaration(members);
 
                 if (token.value == TOK.endOfFile)
                     break;
             }
-            members = symbols;          // `members` will be non-null even with 0 members
-            symbols = symbolsSave;
             check(TOK.rightCurly);
 
             if ((*members).length == 0) // C11 6.7.2.1-8
@@ -3152,7 +3248,7 @@ final class CParser(AST) : Parser!AST
          * redeclaration, or reference to existing declaration.
          * Defer to the semantic() pass with a TypeTag.
          */
-        return new AST.TypeTag(loc, structOrUnion, tag, members);
+        return new AST.TypeTag(loc, structOrUnion, tag, null, members);
     }
 
     /*************************************
@@ -3169,18 +3265,19 @@ final class CParser(AST) : Parser!AST
      * struct-declarator:
      *    declarator
      *    declarator (opt) : constant-expression
+     * Params:
+     *    members = where to put the fields (members)
      */
-    void cparseStructDeclaration()
+    void cparseStructDeclaration(AST.Dsymbols* members)
     {
         //printf("cparseStructDeclaration()\n");
         if (token.value == TOK._Static_assert)
         {
             auto s = cparseStaticAssert();
-            symbols.push(s);
+            members.push(s);
             return;
         }
 
-        auto symbolsSave = symbols;
         Specifier specifier;
         specifier.packalign = this.packalign;
         auto tspec = cparseSpecifierQualifierList(LVL.member, specifier);
@@ -3209,10 +3306,8 @@ final class CParser(AST) : Parser!AST
                  * the containing struct
                  */
                 auto ad = new AST.AnonDeclaration(tt.loc, tt.tok == TOK.union_, tt.members);
-                if (!symbols)
-                    symbols = new AST.Dsymbols();
                 auto s = applySpecifier(ad, specifier);
-                symbols.push(s);
+                members.push(s);
                 return;
             }
             if (!tt.id && !tt.members)
@@ -3270,18 +3365,14 @@ final class CParser(AST) : Parser!AST
             if (token.value == TOK.__attribute__)
                 cparseGnuAttributes(specifier);
 
-            AST.Dsymbol s = null;
-            symbols = symbolsSave;
-            if (!symbols)
-                symbols = new AST.Dsymbols;     // lazilly create it
-
             if (!tspec && !specifier.scw && !specifier.mod)
                 error("specifier-qualifier-list required");
             else if (width)
             {
                 if (specifier.alignExps)
                     error("no alignment-specifier for bit field declaration"); // C11 6.7.5-2
-                s = new AST.BitFieldDeclaration(width.loc, dt, id, width);
+                auto s = new AST.BitFieldDeclaration(width.loc, dt, id, width);
+                members.push(s);
             }
             else if (id)
             {
@@ -3291,11 +3382,10 @@ final class CParser(AST) : Parser!AST
                 // declare the symbol
                 // Give member variables an implicit void initializer
                 auto initializer = new AST.VoidInitializer(token.loc);
-                s = new AST.VarDeclaration(token.loc, dt, id, initializer, specifiersToSTC(LVL.member, specifier));
+                AST.Dsymbol s = new AST.VarDeclaration(token.loc, dt, id, initializer, specifiersToSTC(LVL.member, specifier));
                 s = applySpecifier(s, specifier);
+                members.push(s);
             }
-            if (s !is null)
-                symbols.push(s);
 
             switch (token.value)
             {
@@ -4391,39 +4481,5 @@ final class CParser(AST) : Parser!AST
         return s;
     }
 
-    /***********************************
-     * Add global target-dependent builtin declarations.
-     */
-    private void addBuiltinDeclarations()
-    {
-        void genBuiltinFunc(Identifier id, AST.VarArg va)
-        {
-            auto tva_list = new AST.TypeIdentifier(Loc.initial, Id.builtin_va_list);
-            auto parameters = new AST.Parameters();
-            parameters.push(new AST.Parameter(STC.parameter | STC.ref_, tva_list, null, null, null));
-            auto pl = AST.ParameterList(parameters, va, 0);
-            auto tf = new AST.TypeFunction(pl, AST.Type.tvoid, LINK.c, 0);
-            auto s = new AST.FuncDeclaration(Loc.initial, Loc.initial, id, AST.STC.static_, tf, false);
-            symbols.push(s);
-        }
-
-        /* void __builtin_va_start(__builtin_va_list, ...);
-         * The second argument is supposed to be of any type, so fake it with the ...
-         */
-        genBuiltinFunc(Id.builtin_va_start, AST.VarArg.variadic);
-
-        /* void __builtin_va_end(__builtin_va_list);
-         */
-        genBuiltinFunc(Id.builtin_va_end, AST.VarArg.none);
-
-        /* struct __va_list_tag
-         * {
-         *    uint, uint, void*, void*
-         * }
-         */
-        auto s = new AST.StructDeclaration(Loc.initial, Id.va_list_tag, false);
-        symbols.push(s);
-    }
-
     //}
 }
diff --git a/gcc/d/dmd/cppmangle.d b/gcc/d/dmd/cppmangle.d
index 7cb2092b723..986b53ff74a 100644
--- a/gcc/d/dmd/cppmangle.d
+++ b/gcc/d/dmd/cppmangle.d
@@ -1315,7 +1315,18 @@ private final class CppMangleVisitor : Visitor
 
         foreach (n, fparam; parameterList)
         {
-            Type t = target.cpp.parameterType(fparam);
+            Type t = fparam.type.merge2();
+            if (fparam.isReference())
+                t = t.referenceTo();
+            else if (fparam.storageClass & STC.lazy_)
+            {
+                // Mangle as delegate
+                auto tf = new TypeFunction(ParameterList(), t, LINK.d);
+                auto td = new TypeDelegate(tf);
+                t = td.merge();
+            }
+            else if (Type cpptype = target.cpp.parameterType(t))
+                t = cpptype;
             if (t.ty == Tsarray)
             {
                 // Static arrays in D are passed by value; no counterpart in C++
diff --git a/gcc/d/dmd/dcast.d b/gcc/d/dmd/dcast.d
index 4a80d17c8ed..91b38618e23 100644
--- a/gcc/d/dmd/dcast.d
+++ b/gcc/d/dmd/dcast.d
@@ -858,11 +858,8 @@ MATCH implicitConvTo(Expression e, Type t)
              * convert to immutable
              */
             if (e.f &&
-                (global.params.useDIP1000 != FeatureState.enabled ||        // lots of legacy code breaks with the following purity check
-                 e.f.isPure() >= PURE.strong ||
-                 // Special case exemption for Object.dup() which we assume is implemented correctly
-                 e.f.ident == Id.dup &&
-                 e.f.toParent2() == ClassDeclaration.object.toParent()) &&
+                // lots of legacy code breaks with the following purity check
+                (global.params.useDIP1000 != FeatureState.enabled || e.f.isPure() >= PURE.const_) &&
                  e.f.isReturnIsolated() // check isReturnIsolated last, because it is potentially expensive.
                )
             {
@@ -2245,9 +2242,12 @@ Expression castTo(Expression e, Scope* sc, Type t, Type att = null)
                 ex = ex.castTo(sc, totuple ? (*totuple.arguments)[i].type : t);
                 (*te.exps)[i] = ex;
             }
+            if (totuple)
+                te.type = totuple;
             result = te;
 
-            /* Questionable behavior: In here, result.type is not set to t.
+            /* Questionable behavior: In here, result.type is not set to t
+             *  if target type is not a tuple of same length.
              * Therefoe:
              *  TypeTuple!(int, int) values;
              *  auto values2 = cast(long)values;
diff --git a/gcc/d/dmd/dclass.d b/gcc/d/dmd/dclass.d
index 1fb477901d1..ce463c023f0 100644
--- a/gcc/d/dmd/dclass.d
+++ b/gcc/d/dmd/dclass.d
@@ -446,6 +446,7 @@ extern (C++) class ClassDeclaration : AggregateDeclaration
             *poffset = 0;
         while (cd)
         {
+            assert(cd.baseClass || cd.semanticRun >= PASS.semanticdone || cd.isInterfaceDeclaration());
             if (this == cd.baseClass)
                 return true;
 
diff --git a/gcc/d/dmd/declaration.d b/gcc/d/dmd/declaration.d
index aa143d4369f..494b60f0493 100644
--- a/gcc/d/dmd/declaration.d
+++ b/gcc/d/dmd/declaration.d
@@ -1048,7 +1048,6 @@ extern (C++) class VarDeclaration : Declaration
     uint endlinnum;                 // line number of end of scope that this var lives in
     uint offset;
     uint sequenceNumber;            // order the variables are declared
-    __gshared uint nextSequenceNumber;   // the counter for sequenceNumber
     structalign_t alignment;
 
     // When interpreting, these point to the value (NULL if value not determinable)
@@ -1099,7 +1098,6 @@ extern (C++) class VarDeclaration : Declaration
         this._init = _init;
         ctfeAdrOnStack = AdrOnStackNone;
         this.storage_class = storage_class;
-        sequenceNumber = ++nextSequenceNumber;
     }
 
     static VarDeclaration create(const ref Loc loc, Type type, Identifier ident, Initializer _init, StorageClass storage_class = STC.undefined_)
@@ -1657,12 +1655,10 @@ extern (C++) class VarDeclaration : Declaration
         // Sequence numbers work when there are no special VarDeclaration's involved
         if (!((this.storage_class | v.storage_class) & special))
         {
-            // FIXME: VarDeclaration's for parameters are created in semantic3, so
-            //        they will have a greater sequence number than local variables.
-            //        Hence reverse the result for mixed comparisons.
-            const exp = this.isParameter() == v.isParameter();
+            assert(this.sequenceNumber != this.sequenceNumber.init);
+            assert(v.sequenceNumber != v.sequenceNumber.init);
 
-            return (this.sequenceNumber < v.sequenceNumber) == exp;
+            return (this.sequenceNumber < v.sequenceNumber);
         }
 
         // Assume that semantic produces temporaries according to their lifetime
diff --git a/gcc/d/dmd/denum.d b/gcc/d/dmd/denum.d
index dd6dd41abad..90e48f84d23 100644
--- a/gcc/d/dmd/denum.d
+++ b/gcc/d/dmd/denum.d
@@ -16,6 +16,7 @@ module dmd.denum;
 
 import core.stdc.stdio;
 
+import dmd.astenums;
 import dmd.attrib;
 import dmd.gluelayer;
 import dmd.declaration;
@@ -60,7 +61,7 @@ extern (C++) final class EnumDeclaration : ScopeDsymbol
     extern (D) this(const ref Loc loc, Identifier ident, Type memtype)
     {
         super(loc, ident);
-        //printf("EnumDeclaration() %s\n", toChars());
+        //printf("EnumDeclaration() %p %s : %s\n", this, toChars(), memtype.toChars());
         type = new TypeEnum(this);
         this.memtype = memtype;
         visibility = Visibility(Visibility.Kind.undefined);
diff --git a/gcc/d/dmd/dinterpret.d b/gcc/d/dmd/dinterpret.d
index fb8ed9b2605..b55b98160ff 100644
--- a/gcc/d/dmd/dinterpret.d
+++ b/gcc/d/dmd/dinterpret.d
@@ -99,7 +99,15 @@ public Expression ctfeInterpret(Expression e)
 
     Expression result = interpret(e, null);
 
-    result = copyRegionExp(result);
+    // Report an error if the expression contained a `ThrowException` and
+    // hence generated an uncaught exception
+    if (auto tee = result.isThrownExceptionExp())
+    {
+        tee.generateUncaughtError();
+        result = CTFEExp.cantexp;
+    }
+    else
+        result = copyRegionExp(result);
 
     if (!CTFEExp.isCantExp(result))
         result = scrubReturnValue(e.loc, result);
@@ -1601,14 +1609,20 @@ public:
             istate.start = null;
         }
 
-        incUsageCtfe(istate, s.loc);
+        interpretThrow(s.exp, s.loc);
+    }
+
+    /// Interpret `throw <exp>` found at the specified location `loc`
+    private void interpretThrow(Expression exp, const ref Loc loc)
+    {
+        incUsageCtfe(istate, loc);
 
-        Expression e = interpretRegion(s.exp, istate);
+        Expression e = interpretRegion(exp, istate);
         if (exceptionOrCant(e))
             return;
 
         assert(e.op == EXP.classReference);
-        result = ctfeEmplaceExp!ThrownExceptionExp(s.loc, e.isClassReferenceExp());
+        result = ctfeEmplaceExp!ThrownExceptionExp(loc, e.isClassReferenceExp());
     }
 
     override void visit(ScopeGuardStatement s)
@@ -6149,6 +6163,15 @@ public:
         return;
     }
 
+    override void visit(ThrowExp te)
+    {
+        debug (LOG)
+        {
+            printf("%s ThrowExpression::interpret()\n", e.loc.toChars());
+        }
+        interpretThrow(te.e1, te.loc);
+    }
+
     override void visit(PtrExp e)
     {
         debug (LOG)
diff --git a/gcc/d/dmd/dscope.d b/gcc/d/dmd/dscope.d
index 07ebc27a69b..2a3777b3df0 100644
--- a/gcc/d/dmd/dscope.d
+++ b/gcc/d/dmd/dscope.d
@@ -59,7 +59,6 @@ enum SCOPE
     compile       = 0x0100,   /// inside __traits(compile)
     ignoresymbolvisibility    = 0x0200,   /// ignore symbol visibility
                                           /// https://issues.dlang.org/show_bug.cgi?id=15907
-    onlysafeaccess = 0x0400,  /// unsafe access is not allowed for @safe code
     Cfile         = 0x0800,   /// C semantics apply
     free          = 0x8000,   /// is on free list
 
@@ -74,7 +73,7 @@ enum SCOPE
 /// Flags that are carried along with a scope push()
 private enum PersistentFlags =
     SCOPE.contract | SCOPE.debug_ | SCOPE.ctfe | SCOPE.compile | SCOPE.constraint |
-    SCOPE.noaccesscheck | SCOPE.onlysafeaccess | SCOPE.ignoresymbolvisibility |
+    SCOPE.noaccesscheck | SCOPE.ignoresymbolvisibility |
     SCOPE.printf | SCOPE.scanf | SCOPE.Cfile;
 
 struct Scope
diff --git a/gcc/d/dmd/dsymbol.d b/gcc/d/dmd/dsymbol.d
index c4b3380e3aa..7823351b579 100644
--- a/gcc/d/dmd/dsymbol.d
+++ b/gcc/d/dmd/dsymbol.d
@@ -2345,7 +2345,7 @@ extern (C++) final class DsymbolTable : RootObject
 Dsymbol handleTagSymbols(ref Scope sc, Dsymbol s, Dsymbol s2, ScopeDsymbol sds)
 {
     enum log = false;
-    if (log) printf("handleTagSymbols('%s')\n", s.toChars());
+    if (log) printf("handleTagSymbols('%s') add %p existing %p\n", s.toChars(), s, s2);
     auto sd = s.isScopeDsymbol(); // new declaration
     auto sd2 = s2.isScopeDsymbol(); // existing declaration
 
diff --git a/gcc/d/dmd/dsymbolsem.d b/gcc/d/dmd/dsymbolsem.d
index 387dfe33098..1cb167ae18c 100644
--- a/gcc/d/dmd/dsymbolsem.d
+++ b/gcc/d/dmd/dsymbolsem.d
@@ -356,6 +356,8 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         if (sc && sc.inunion && sc.inunion.isAnonDeclaration())
             dsym.overlapped = true;
 
+        dsym.sequenceNumber = global.varSequenceNumber++;
+
         Scope* scx = null;
         if (dsym._scope)
         {
@@ -1636,7 +1638,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
 
         // Should be merged with PragmaStatement
         //printf("\tPragmaDeclaration::semantic '%s'\n", pd.toChars());
-        if (target.mscoff)
+        if (target.supportsLinkerDirective())
         {
             if (pd.ident == Id.linkerDirective)
             {
@@ -2177,7 +2179,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         {
             /* C11 6.7.2.2
              */
-            ed.memtype = Type.tint32; // C11 6.7.2.2-4 implementation defined
+            assert(ed.memtype);
             int nextValue = 0;        // C11 6.7.2.2-3 first member value defaults to 0
 
             void emSemantic(EnumMember em, ref int nextValue)
@@ -3457,9 +3459,11 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
                     }
                 }
 
-                /* These quirky conditions mimic what VC++ appears to do
+                /* These quirky conditions mimic what happens when virtual
+                   inheritance is implemented by producing a virtual base table
+                   with offsets to each of the virtual bases.
                  */
-                if (target.mscoff && cd.classKind == ClassKind.cpp &&
+                if (target.cpp.splitVBasetable && cd.classKind == ClassKind.cpp &&
                     cd.baseClass && cd.baseClass.vtbl.dim)
                 {
                     /* if overriding an interface function, then this is not
@@ -3557,7 +3561,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
                             goto Lintro;
                     }
 
-                    if (fdv.isDeprecated)
+                    if (fdv.isDeprecated && !funcdecl.isDeprecated)
                         deprecation(funcdecl.loc, "`%s` is overriding the deprecated method `%s`",
                                     funcdecl.toPrettyChars, fdv.toPrettyChars);
 
@@ -3646,11 +3650,17 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
                         funcdecl.tintro = fdv.tintro;
                     else if (!funcdecl.type.equals(fdv.type))
                     {
+                        auto tnext = funcdecl.type.nextOf();
+                        if (auto handle = tnext.isClassHandle())
+                        {
+                            if (handle.semanticRun < PASS.semanticdone && !handle.isBaseInfoComplete())
+                                handle.dsymbolSemantic(null);
+                        }
                         /* Only need to have a tintro if the vptr
                          * offsets differ
                          */
                         int offset;
-                        if (fdv.type.nextOf().isBaseOf(funcdecl.type.nextOf(), &offset))
+                        if (fdv.type.nextOf().isBaseOf(tnext, &offset))
                         {
                             funcdecl.tintro = fdv.type;
                         }
@@ -3812,7 +3822,8 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
                     deprecation(funcdecl.loc,
                                 "`%s` cannot be annotated with `@disable` because it is overriding a function in the base class",
                                 funcdecl.toPrettyChars);
-                if (funcdecl.isDeprecated)
+
+                if (funcdecl.isDeprecated && !(funcdecl.foverrides.length && funcdecl.foverrides[0].isDeprecated))
                     deprecation(funcdecl.loc,
                                 "`%s` cannot be marked as `deprecated` because it is overriding a function in the base class",
                                 funcdecl.toPrettyChars);
diff --git a/gcc/d/dmd/dtemplate.d b/gcc/d/dmd/dtemplate.d
index c0d17f744be..9fe8472b11e 100644
--- a/gcc/d/dmd/dtemplate.d
+++ b/gcc/d/dmd/dtemplate.d
@@ -6223,114 +6223,62 @@ extern (C++) class TemplateInstance : ScopeDsymbol
      */
     final bool needsCodegen()
     {
-        if (!minst)
-        {
-            // If this is a speculative instantiation,
-            // 1. do codegen if ancestors really needs codegen.
-            // 2. become non-speculative if siblings are not speculative
-
-            TemplateInstance tnext = this.tnext;
-            TemplateInstance tinst = this.tinst;
-            // At first, disconnect chain first to prevent infinite recursion.
-            this.tnext = null;
-            this.tinst = null;
+        // minst is finalized after the 1st invocation.
+        // tnext and tinst are only needed for the 1st invocation and
+        // cleared for further invocations.
+        TemplateInstance tnext = this.tnext;
+        TemplateInstance tinst = this.tinst;
+        this.tnext = null;
+        this.tinst = null;
 
-            // Determine necessity of tinst before tnext.
-            if (tinst && tinst.needsCodegen())
-            {
-                minst = tinst.minst; // cache result
-                if (global.params.allInst && minst)
-                {
-                    return true;
-                }
-                assert(minst);
-                assert(minst.isRoot() || minst.rootImports());
-                return true;
-            }
-            if (tnext && (tnext.needsCodegen() || tnext.minst))
-            {
-                minst = tnext.minst; // cache result
-                if (global.params.allInst && minst)
-                {
-                    return true;
-                }
-                assert(minst);
-                return minst.isRoot() || minst.rootImports();
-            }
-
-            // Elide codegen because this is really speculative.
-            return false;
-        }
-
-        if (global.params.allInst)
-        {
-            return true;
-        }
-
-        if (isDiscardable())
+        if (errors || (inst && inst.isDiscardable()))
         {
+            minst = null; // mark as speculative
             return false;
         }
 
-        /* Even when this is reached to the codegen pass,
-         * a non-root nested template should not generate code,
-         * due to avoid ODR violation.
-         */
-        if (enclosing && enclosing.inNonRoot())
+        if (global.params.allInst)
         {
-            if (tinst)
-            {
-                auto r = tinst.needsCodegen();
-                minst = tinst.minst; // cache result
-                return r;
-            }
-            if (tnext)
-            {
-                auto r = tnext.needsCodegen();
-                minst = tnext.minst; // cache result
-                return r;
-            }
-            return false;
-        }
+            // Do codegen if there is an instantiation from a root module, to maximize link-ability.
 
-        if (global.params.useUnitTests)
-        {
-            // Prefer instantiations from root modules, to maximize link-ability.
-            if (minst.isRoot())
+            // Do codegen if `this` is instantiated from a root module.
+            if (minst && minst.isRoot())
                 return true;
 
-            TemplateInstance tnext = this.tnext;
-            TemplateInstance tinst = this.tinst;
-            this.tnext = null;
-            this.tinst = null;
-
+            // Do codegen if the ancestor needs it.
             if (tinst && tinst.needsCodegen())
             {
                 minst = tinst.minst; // cache result
                 assert(minst);
-                assert(minst.isRoot() || minst.rootImports());
+                assert(minst.isRoot());
                 return true;
             }
-            if (tnext && tnext.needsCodegen())
+
+            // Do codegen if a sibling needs it.
+            if (tnext)
             {
-                minst = tnext.minst; // cache result
-                assert(minst);
-                assert(minst.isRoot() || minst.rootImports());
-                return true;
+                if (tnext.needsCodegen())
+                {
+                    minst = tnext.minst; // cache result
+                    assert(minst);
+                    assert(minst.isRoot());
+                    return true;
+                }
+                else if (!minst && tnext.minst)
+                {
+                    minst = tnext.minst; // cache result from non-speculative sibling
+                    return false;
+                }
             }
 
-            // https://issues.dlang.org/show_bug.cgi?id=2500 case
-            if (minst.rootImports())
-                return true;
-
-            // Elide codegen because this is not included in root instances.
+            // Elide codegen because there's no instantiation from any root modules.
             return false;
         }
         else
         {
-            // Prefer instantiations from non-root module, to minimize object code size.
+            // Prefer instantiations from non-root modules, to minimize object code size.
 
-            /* If a TemplateInstance is ever instantiated by non-root modules,
+            /* If a TemplateInstance is ever instantiated from a non-root module,
              * we do not have to generate code for it,
              * because it will be generated when the non-root module is compiled.
              *
@@ -6341,22 +6289,51 @@ extern (C++) class TemplateInstance : ScopeDsymbol
              * or the compilation of B do the actual instantiation?
              *
              * See https://issues.dlang.org/show_bug.cgi?id=2500.
+             *
+             * => Elide codegen if there is at least one instantiation from a non-root module
+             *    which doesn't import any root modules.
              */
-            if (!minst.isRoot() && !minst.rootImports())
-                return false;
 
-            TemplateInstance tnext = this.tnext;
-            this.tnext = null;
-
-            if (tnext && !tnext.needsCodegen() && tnext.minst)
+            // If the ancestor isn't speculative,
+            // 1. do codegen if the ancestor needs it
+            // 2. elide codegen if the ancestor doesn't need it (non-root instantiation of ancestor incl. subtree)
+            if (tinst)
             {
-                minst = tnext.minst; // cache result
-                assert(!minst.isRoot());
+                const needsCodegen = tinst.needsCodegen(); // sets tinst.minst
+                if (tinst.minst) // not speculative
+                {
+                    minst = tinst.minst; // cache result
+                    return needsCodegen;
+                }
+            }
+
+            // Elide codegen if `this` doesn't need it.
+            if (minst && !minst.isRoot() && !minst.rootImports())
                 return false;
+
+            // Elide codegen if a (non-speculative) sibling doesn't need it.
+            if (tnext)
+            {
+                const needsCodegen = tnext.needsCodegen(); // sets tnext.minst
+                if (tnext.minst) // not speculative
+                {
+                    if (!needsCodegen)
+                    {
+                        minst = tnext.minst; // cache result
+                        assert(!minst.isRoot() && !minst.rootImports());
+                        return false;
+                    }
+                    else if (!minst)
+                    {
+                        minst = tnext.minst; // cache result from non-speculative sibling
+                        return true;
+                    }
+                }
             }
 
-            // Do codegen because this is not included in non-root instances.
-            return true;
+            // Unless `this` is still speculative (=> all further siblings speculative too),
+            // do codegen because we found no guaranteed-codegen'd non-root instantiation.
+            return minst !is null;
         }
     }
 
@@ -7311,7 +7288,7 @@ extern (C++) class TemplateInstance : ScopeDsymbol
                 if ((td && td.literal) || (ti && ti.enclosing) || (d && !d.isDataseg() && !(d.storage_class & STC.manifest) && (!d.isFuncDeclaration() || d.isFuncDeclaration().isNested()) && !isTemplateMixin()))
                 {
                     Dsymbol dparent = sa.toParent2();
-                    if (!dparent)
+                    if (!dparent || dparent.isModule)
                         goto L1;
                     else if (!enclosing)
                         enclosing = dparent;
@@ -7370,13 +7347,6 @@ extern (C++) class TemplateInstance : ScopeDsymbol
     {
         Module mi = minst; // instantiated . inserted module
 
-        if (global.params.useUnitTests)
-        {
-            // Turn all non-root instances to speculative
-            if (mi && !mi.isRoot())
-                mi = null;
-        }
-
         //printf("%s.appendToModuleMember() enclosing = %s mi = %s\n",
         //    toPrettyChars(),
         //    enclosing ? enclosing.toPrettyChars() : null,
diff --git a/gcc/d/dmd/dtoh.d b/gcc/d/dmd/dtoh.d
index dbc21b3b6dd..5871ada466d 100644
--- a/gcc/d/dmd/dtoh.d
+++ b/gcc/d/dmd/dtoh.d
@@ -16,6 +16,7 @@ import core.stdc.string;
 import core.stdc.ctype;
 
 import dmd.astcodegen;
+import dmd.astenums;
 import dmd.arraytypes;
 import dmd.attrib;
 import dmd.dsymbol;
diff --git a/gcc/d/dmd/escape.d b/gcc/d/dmd/escape.d
index e60ee9c8f54..d2a90609c16 100644
--- a/gcc/d/dmd/escape.d
+++ b/gcc/d/dmd/escape.d
@@ -691,11 +691,8 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag)
             }
 
             // If va's lifetime encloses v's, then error
-            if (va &&
-                (va.enclosesLifetimeOf(v) && !(v.storage_class & (STC.parameter | STC.temp)) ||
-                 // va is class reference
-                 ae.e1.isDotVarExp() && va.type.toBasetype().isTypeClass() && (va.enclosesLifetimeOf(v) ||
-                 !va.isScope()) ||
+            if (va && !va.isDataseg() &&
+                (va.enclosesLifetimeOf(v) && !(v.storage_class & STC.temp) ||
                  vaIsRef ||
                  va.isReference() && !(v.storage_class & (STC.parameter | STC.temp))) &&
                 fd.setUnsafe())
@@ -768,7 +765,6 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag)
         }
     }
 
-ByRef:
     foreach (VarDeclaration v; er.byref)
     {
         if (log) printf("byref: %s\n", v.toChars());
@@ -797,8 +793,7 @@ ByRef:
 
         // If va's lifetime encloses v's, then error
         if (va &&
-            (va.enclosesLifetimeOf(v) && !(v.isParameter() && v.isRef()) ||
-             va.isDataseg()) &&
+            (va.enclosesLifetimeOf(v) || (va.isRef() && !(va.storage_class & STC.temp)) || va.isDataseg()) &&
             fd.setUnsafe())
         {
             if (!gag)
@@ -807,26 +802,6 @@ ByRef:
             continue;
         }
 
-        if (va && v.isReference())
-        {
-            Dsymbol pva = va.toParent2();
-            for (Dsymbol pv = p; pv; )
-            {
-                pv = pv.toParent2();
-                if (pva == pv)  // if v is nested inside pva
-                {
-                    if (fd.setUnsafe())
-                    {
-                        if (!gag)
-                            error(ae.loc, "reference `%s` assigned to `%s` with longer lifetime", v.toChars(), va.toChars());
-                        result = true;
-                        continue ByRef;
-                    }
-                    break;
-                }
-            }
-        }
-
         if (!(va && va.isScope()))
             notMaybeScope(v);
 
@@ -1323,7 +1298,9 @@ private bool checkReturnEscapeImpl(Scope* sc, Expression e, bool refs, bool gag)
                     msg = "returning `%s` escapes a reference to parameter `%s`";
                     supplemental = vsr == ScopeRef.Ref_ReturnScope
                                               ? "perhaps remove `scope` parameter annotation so `return` applies to `ref`"
-                                              : "perhaps annotate the parameter with `return`";
+                                              : v.ident is Id.This
+                                                    ? "perhaps annotate the function with `return`"
+                                                    : "perhaps annotate the parameter with `return`";
                 }
                 else
                 {
diff --git a/gcc/d/dmd/expression.d b/gcc/d/dmd/expression.d
index 523015e1a68..4258e9ba49e 100644
--- a/gcc/d/dmd/expression.d
+++ b/gcc/d/dmd/expression.d
@@ -25,7 +25,6 @@ import dmd.arraytypes;
 import dmd.astenums;
 import dmd.ast_node;
 import dmd.gluelayer;
-import dmd.canthrow;
 import dmd.constfold;
 import dmd.ctfeexpr;
 import dmd.ctorflow;
@@ -466,7 +465,17 @@ private Expression callCpCtor(Scope* sc, Expression e, Type destinationType)
              */
             auto tmp = copyToTemp(STC.rvalue, "__copytmp", e);
             if (sd.hasCopyCtor && destinationType)
-                tmp.type = destinationType;
+            {
+                // https://issues.dlang.org/show_bug.cgi?id=22619
+                // If the destination type is inout we can preserve it
+                // only if inside an inout function; if we are not inside
+                // an inout function, then we will preserve the type of
+                // the source
+                if (destinationType.hasWild && !(sc.func.storage_class & STC.wild))
+                    tmp.type = e.type;
+                else
+                    tmp.type = destinationType;
+            }
             tmp.storage_class |= STC.nodtor;
             tmp.dsymbolSemantic(sc);
             Expression de = new DeclarationExp(e.loc, tmp);
@@ -4680,6 +4689,31 @@ extern (C++) final class AssertExp : UnaExp
     }
 }
 
+/***********************************************************
+ * `throw <e1>` as proposed by DIP 1034.
+ *
+ * Replacement for the deprecated `ThrowStatement` that can be nested
+ * in other expression.
+ */
+extern (C++) final class ThrowExp : UnaExp
+{
+    extern (D) this(const ref Loc loc, Expression e)
+    {
+        super(loc, EXP.throw_, __traits(classInstanceSize, ThrowExp), e);
+        this.type = Type.tnoreturn;
+    }
+
+    override ThrowExp syntaxCopy()
+    {
+        return new ThrowExp(loc, e1.syntaxCopy());
+    }
+
+    override void accept(Visitor v)
+    {
+        v.visit(this);
+    }
+}
+
 /***********************************************************
  */
 extern (C++) final class DotIdExp : UnaExp
diff --git a/gcc/d/dmd/expression.h b/gcc/d/dmd/expression.h
index f848cce72a9..18ef90a56a7 100644
--- a/gcc/d/dmd/expression.h
+++ b/gcc/d/dmd/expression.h
@@ -48,7 +48,9 @@ struct Symbol;          // back end symbol
 void expandTuples(Expressions *exps);
 bool isTrivialExp(Expression *e);
 bool hasSideEffect(Expression *e, bool assumeImpureCalls = false);
-bool canThrow(Expression *e, FuncDeclaration *func, bool mustNotThrow);
+
+enum BE : int32_t;
+BE canThrow(Expression *e, FuncDeclaration *func, bool mustNotThrow);
 
 typedef unsigned char OwnedBy;
 enum
@@ -742,6 +744,14 @@ public:
     void accept(Visitor *v) { v->visit(this); }
 };
 
+class ThrowExp : public UnaExp
+{
+public:
+    ThrowExp *syntaxCopy();
+
+    void accept(Visitor *v) { v->visit(this); }
+};
+
 class DotIdExp : public UnaExp
 {
 public:
diff --git a/gcc/d/dmd/expressionsem.d b/gcc/d/dmd/expressionsem.d
index 100860612dc..6eda6888077 100644
--- a/gcc/d/dmd/expressionsem.d
+++ b/gcc/d/dmd/expressionsem.d
@@ -3604,16 +3604,21 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
                 {
                     if (!cdthis)
                     {
+                        if (!sc.hasThis)
+                        {
+                            string msg = "cannot construct " ~
+                            (cd.isAnonymous ? "anonymous nested class" : "nested class `%s`") ~
+                            " because no implicit `this` reference to outer class" ~
+                            (cdn.isAnonymous ? "" : " `%s`") ~ " is available\0";
+
+                            exp.error(msg.ptr, cd.toChars, cdn.toChars);
+                            return setError();
+                        }
+
                         // Supply an implicit 'this' and try again
                         exp.thisexp = new ThisExp(exp.loc);
                         for (Dsymbol sp = sc.parent; 1; sp = sp.toParentLocal())
                         {
-                            if (!sp)
-                            {
-                                exp.error("outer class `%s` `this` needed to `new` nested class `%s`",
-                                    cdn.toChars(), cd.toChars());
-                                return setError();
-                            }
                             ClassDeclaration cdp = sp.isClassDeclaration();
                             if (!cdp)
                                 continue;
@@ -5702,12 +5707,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
                     || global.params.useDeprecated != DiagnosticReporting.error;
                 const bool preventAliasThis = e.targ.hasDeprecatedAliasThis && !deprecationAllowed;
 
-                // baseClass might not be set if either targ or tspec is forward referenced.
-                if (auto tc = e.targ.isTypeClass())
-                    tc.sym.dsymbolSemantic(null);
-                if (auto tc = e.tspec.isTypeClass())
-                    tc.sym.dsymbolSemantic(null);
-
                 if (preventAliasThis && e.targ.ty == Tstruct)
                 {
                     if ((cast(TypeStruct) e.targ).implicitConvToWithoutAliasThis(e.tspec))
@@ -6396,6 +6395,16 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             : Expression.combine(temporariesPrefix, exp).expressionSemantic(sc);
     }
 
+    override void visit(ThrowExp te)
+    {
+        import dmd.statementsem;
+
+        if (StatementSemanticVisitor.throwSemantic(te.loc, te.e1, sc))
+            result = te;
+        else
+            setError();
+    }
+
     override void visit(DotIdExp exp)
     {
         static if (LOGSEMANTIC)
@@ -6913,6 +6922,18 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             exp.error("cannot take address of `%s`", exp.e1.toChars());
             return setError();
         }
+        if (auto dve = exp.e1.isDotVarExp())
+        {
+            /* https://issues.dlang.org/show_bug.cgi?id=22749
+             * Error about taking address of any bit-field, regardless of
+             * whether SCOPE.Cfile is set.
+             */
+            if (auto bf = dve.var.isBitFieldDeclaration())
+            {
+                exp.error("cannot take address of bit-field `%s`", bf.toChars());
+                return setError();
+            }
+        }
 
         bool hasOverloads;
         if (auto f = isFuncAddress(exp, &hasOverloads))
@@ -7511,6 +7532,17 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
         // https://issues.dlang.org/show_bug.cgi?id=19954
         if (exp.e1.type.ty == Ttuple)
         {
+            if (exp.to)
+            {
+                if (TypeTuple tt = exp.to.isTypeTuple())
+                {
+                    if (exp.e1.type.implicitConvTo(tt))
+                    {
+                        result = exp.e1.castTo(sc, tt);
+                        return;
+                    }
+                }
+            }
             TupleExp te = exp.e1.isTupleExp();
             if (te.exps.dim == 1)
                 exp.e1 = (*te.exps)[0];
@@ -7531,7 +7563,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
 
         if (exp.to.ty == Ttuple)
         {
-            exp.error("cannot cast `%s` to tuple type `%s`", exp.e1.toChars(), exp.to.toChars());
+            exp.error("cannot cast `%s` of type `%s` to tuple type `%s`", exp.e1.toChars(), exp.e1.type.toChars(), exp.to.toChars());
             return setError();
         }
 
@@ -8016,7 +8048,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
                 Expression el = new ArrayLengthExp(exp.loc, exp.e1);
                 el = el.expressionSemantic(sc);
                 el = el.optimize(WANTvalue);
-                if (el.op == EXP.int64)
+                if (el.op == EXP.int64 && t1b.ty == Tsarray)
                 {
                     // Array length is known at compile-time. Upper is in bounds if it fits length.
                     dinteger_t length = el.toInteger();
@@ -9894,7 +9926,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
                 Expression id = new IdentifierExp(exp.loc, Id.empty);
                 id = new DotIdExp(exp.loc, id, Id.object);
                 id = new DotIdExp(exp.loc, id, func);
-                id = id.expressionSemantic(sc);
 
                 auto arguments = new Expressions();
                 arguments.push(new CastExp(ae.loc, ae.e1, ae.e1.type.nextOf.arrayOf).expressionSemantic(sc));
@@ -11355,7 +11386,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             return setError();
         }
 
-        EXP cmpop;
+
+        EXP cmpop = exp.op;
         if (auto e = exp.op_overload(sc, &cmpop))
         {
             if (!e.type.isscalar() && e.type.equals(exp.e1.type))
@@ -11365,6 +11397,38 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             }
             if (e.op == EXP.call)
             {
+
+                if (t1.ty == Tclass && t2.ty == Tclass)
+                {
+                    // Lower to object.__cmp(e1, e2)
+                    Expression cl = new IdentifierExp(exp.loc, Id.empty);
+                    cl = new DotIdExp(exp.loc, cl, Id.object);
+                    cl = new DotIdExp(exp.loc, cl, Id.__cmp);
+                    cl = cl.expressionSemantic(sc);
+
+                    auto arguments = new Expressions();
+                    // Check if op_overload found a better match by calling e2.opCmp(e1)
+                    // If the operands were swapped, then the result must be reversed
+                    // e1.opCmp(e2) == -e2.opCmp(e1)
+                    // cmpop takes care of this
+                    if (exp.op == cmpop)
+                    {
+                        arguments.push(exp.e1);
+                        arguments.push(exp.e2);
+                    }
+                    else
+                    {
+                        // Use better match found by op_overload
+                        arguments.push(exp.e2);
+                        arguments.push(exp.e1);
+                    }
+
+                    cl = new CallExp(exp.loc, cl, arguments);
+                    cl = new CmpExp(cmpop, exp.loc, cl, new IntegerExp(0));
+                    result = cl.expressionSemantic(sc);
+                    return;
+                }
+
                 e = new CmpExp(cmpop, exp.loc, e, IntegerExp.literal!0);
                 e = e.expressionSemantic(sc);
             }
@@ -11372,6 +11436,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             return;
         }
 
+
         if (Expression ex = typeCombine(exp, sc))
         {
             result = ex;
@@ -13213,7 +13278,16 @@ Expression getVarExp(EnumMember em, const ref Loc loc, Scope* sc)
     if (em.errors)
         return ErrorExp.get();
     Expression e = new VarExp(loc, em);
-    return e.expressionSemantic(sc);
+    e = e.expressionSemantic(sc);
+    if (!(sc.flags & SCOPE.Cfile) && em.isCsymbol())
+    {
+        /* C11 types them as int. But if in D file,
+         * type qualified names as the enum
+         */
+        e.type = em.parent.isEnumDeclaration().type;
+        assert(e.type);
+    }
+    return e;
 }
 
 
@@ -13245,6 +13319,8 @@ Expression toBoolean(Expression exp, Scope* sc)
         case EXP.assign:
         case EXP.construct:
         case EXP.blit:
+            if (sc.flags & SCOPE.Cfile)
+                return exp;
             // Things like:
             //  if (a = b) ...
             // are usually mistakes.
diff --git a/gcc/d/dmd/func.d b/gcc/d/dmd/func.d
index b5148be30bd..f3aeb0ff3dc 100644
--- a/gcc/d/dmd/func.d
+++ b/gcc/d/dmd/func.d
@@ -3052,7 +3052,7 @@ FuncDeclaration resolveFuncCall(const ref Loc loc, Scope* sc, Dsymbol s,
         // all of overloads are templates
         if (td)
         {
-            .error(loc, "%s `%s.%s` cannot deduce function from argument types `!(%s)%s`",
+            .error(loc, "none of the overloads of %s `%s.%s` are callable using argument types `!(%s)%s`",
                    td.kind(), td.parent.toPrettyChars(), td.ident.toChars(),
                    tiargsBuf.peekChars(), fargsBuf.peekChars());
 
diff --git a/gcc/d/dmd/globals.d b/gcc/d/dmd/globals.d
index 22ccdddc029..eccd1ee183d 100644
--- a/gcc/d/dmd/globals.d
+++ b/gcc/d/dmd/globals.d
@@ -327,6 +327,7 @@ extern (C++) struct Global
     Array!Identifier* debugids;   /// command line debug versions and predefined versions
 
     bool hasMainFunction; /// Whether a main function has already been compiled in (for -main switch)
+    uint varSequenceNumber = 1; /// Relative lifetime of `VarDeclaration` within a function, used for `scope` checks
 
     enum recursionLimit = 500; /// number of recursive template expansions before abort
 
@@ -614,48 +615,5 @@ nothrow:
     }
 }
 
-/// A linkage attribute as defined by `extern(XXX)`
-///
-/// https://dlang.org/spec/attribute.html#linkage
-enum LINK : ubyte
-{
-    default_,
-    d,
-    c,
-    cpp,
-    windows,
-    objc,
-    system,
-}
-
-/// Whether to mangle an external aggregate as a struct or class, as set by `extern(C++, struct)`
-enum CPPMANGLE : ubyte
-{
-    def,      /// default
-    asStruct, /// `extern(C++, struct)`
-    asClass,  /// `extern(C++, class)`
-}
-
-/// Function match levels
-///
-/// https://dlang.org/spec/function.html#function-overloading
-enum MATCH : int
-{
-    nomatch,   /// no match
-    convert,   /// match with conversions
-    constant,  /// match with conversion to const
-    exact,     /// exact match
-}
-
-/// Inline setting as defined by `pragma(inline, XXX)`
-enum PINLINE : ubyte
-{
-    default_, /// as specified on the command line
-    never,    /// never inline
-    always,   /// always inline
-}
-
-alias StorageClass = ulong;
-
 /// Collection of global state
 extern (C++) __gshared Global global;
diff --git a/gcc/d/dmd/globals.h b/gcc/d/dmd/globals.h
index 4e76967ee22..49fa5b98e95 100644
--- a/gcc/d/dmd/globals.h
+++ b/gcc/d/dmd/globals.h
@@ -290,6 +290,7 @@ struct Global
     Array<class Identifier*>* debugids;   // command line debug versions and predefined versions
 
     bool hasMainFunction;
+    unsigned varSequenceNumber;
 
     /* Start gagging. Return the current number of gagged errors
      */
diff --git a/gcc/d/dmd/hdrgen.d b/gcc/d/dmd/hdrgen.d
index 6fc86c382a1..43b63f147ce 100644
--- a/gcc/d/dmd/hdrgen.d
+++ b/gcc/d/dmd/hdrgen.d
@@ -2364,6 +2364,12 @@ public:
         buf.writeByte(')');
     }
 
+    override void visit(ThrowExp e)
+    {
+        buf.writestring("throw ");
+        expToBuffer(e.e1, PREC.unary, buf, hgs);
+    }
+
     override void visit(DotIdExp e)
     {
         expToBuffer(e.e1, PREC.primary, buf, hgs);
@@ -3896,6 +3902,11 @@ private void typeToBufferx(Type t, OutBuffer* buf, HdrGenState* hgs)
         buf.writeByte(' ');
         if (t.id)
             buf.writestring(t.id.toChars());
+        if (t.base.ty != TY.Tint32)
+        {
+            buf.writestring(" : ");
+            visitWithMask(t.base, t.mod, buf, hgs);
+        }
     }
 
     void visitTuple(TypeTuple t)
diff --git a/gcc/d/dmd/id.d b/gcc/d/dmd/id.d
index cef1b8e80ec..7f51e929ad4 100644
--- a/gcc/d/dmd/id.d
+++ b/gcc/d/dmd/id.d
@@ -478,6 +478,7 @@ immutable Msgtable[] msgtable =
     { "hasCopyConstructor" },
     { "isCopyable" },
     { "toType" },
+    { "parameters" },
 
     // For C++ mangling
     { "allocator" },
@@ -507,12 +508,11 @@ immutable Msgtable[] msgtable =
     { "__func__" },
     { "noreturn" },
     { "__pragma", "pragma" },
+    { "builtins", "__builtins" },
     { "builtin_va_list", "__builtin_va_list" },
-    { "builtin_va_start", "__builtin_va_start" },
     { "builtin_va_arg", "__builtin_va_arg" },
-    { "builtin_va_copy", "__builtin_va_copy" },
-    { "builtin_va_end", "__builtin_va_end" },
     { "va_list_tag", "__va_list_tag" },
+    { "va_arg" },
     { "pack" },
     { "show" },
     { "push" },
diff --git a/gcc/d/dmd/json.d b/gcc/d/dmd/json.d
index ba2dd179423..3183c8dbb79 100644
--- a/gcc/d/dmd/json.d
+++ b/gcc/d/dmd/json.d
@@ -302,8 +302,7 @@ public:
             //property(name, "impure");
             break;
         case PURE.weak:     return property(name, "weak");
-        case PURE.const_:   return property(name, "const");
-        case PURE.strong:   return property(name, "strong");
+        case PURE.const_:   return property(name, "strong");
         case PURE.fwdref:   return property(name, "fwdref");
         }
     }
diff --git a/gcc/d/dmd/mtype.d b/gcc/d/dmd/mtype.d
index 0257faa65b7..fefad2823fe 100644
--- a/gcc/d/dmd/mtype.d
+++ b/gcc/d/dmd/mtype.d
@@ -230,6 +230,57 @@ bool isSomeChar(TY ty) pure nothrow @nogc @safe
     return ty == Tchar || ty == Twchar || ty == Tdchar;
 }
 
+/************************************
+ * Determine mutability of indirections in (ref) t.
+ *
+ * Returns: When the type has any mutable indirections, returns 0.
+ * When all indirections are immutable, returns 2.
+ * Otherwise, when the type has const/inout indirections, returns 1.
+ *
+ * Params:
+ *      isref = if true, check `ref t`; otherwise, check just `t`
+ *      t = the type that is being checked
+ */
+int mutabilityOfType(bool isref, Type t)
+{
+    if (isref)
+    {
+        if (t.mod & MODFlags.immutable_)
+            return 2;
+        if (t.mod & (MODFlags.const_ | MODFlags.wild))
+            return 1;
+        return 0;
+    }
+
+    t = t.baseElemOf();
+
+    if (!t.hasPointers() || t.mod & MODFlags.immutable_)
+        return 2;
+
+    /* Accept immutable(T)[] and immutable(T)* as being strongly pure
+     */
+    if (t.ty == Tarray || t.ty == Tpointer)
+    {
+        Type tn = t.nextOf().toBasetype();
+        if (tn.mod & MODFlags.immutable_)
+            return 2;
+        if (tn.mod & (MODFlags.const_ | MODFlags.wild))
+            return 1;
+    }
+
+    /* The rest of this is too strict; fix later.
+     * For example, the only pointer members of a struct may be immutable,
+     * which would maintain strong purity.
+     * (Just like for dynamic arrays and pointers above.)
+     */
+    if (t.mod & (MODFlags.const_ | MODFlags.wild))
+        return 1;
+
+    /* Should catch delegates and function pointers, and fold in their purity
+     */
+    return 0;
+}
+
 /****************
  * dotExp() bit flags
  */
@@ -4217,54 +4268,11 @@ extern (C++) final class TypeFunction : TypeNext
         if (tf.purity != PURE.fwdref)
             return;
 
-        /* Determine purity level based on mutability of t
-         * and whether it is a 'ref' type or not.
-         */
-        static PURE purityOfType(bool isref, Type t)
-        {
-            if (isref)
-            {
-                if (t.mod & MODFlags.immutable_)
-                    return PURE.strong;
-                if (t.mod & (MODFlags.const_ | MODFlags.wild))
-                    return PURE.const_;
-                return PURE.weak;
-            }
-
-            t = t.baseElemOf();
-
-            if (!t.hasPointers() || t.mod & MODFlags.immutable_)
-                return PURE.strong;
-
-            /* Accept immutable(T)[] and immutable(T)* as being strongly pure
-             */
-            if (t.ty == Tarray || t.ty == Tpointer)
-            {
-                Type tn = t.nextOf().toBasetype();
-                if (tn.mod & MODFlags.immutable_)
-                    return PURE.strong;
-                if (tn.mod & (MODFlags.const_ | MODFlags.wild))
-                    return PURE.const_;
-            }
-
-            /* The rest of this is too strict; fix later.
-             * For example, the only pointer members of a struct may be immutable,
-             * which would maintain strong purity.
-             * (Just like for dynamic arrays and pointers above.)
-             */
-            if (t.mod & (MODFlags.const_ | MODFlags.wild))
-                return PURE.const_;
-
-            /* Should catch delegates and function pointers, and fold in their purity
-             */
-            return PURE.weak;
-        }
-
-        purity = PURE.strong; // assume strong until something weakens it
+        purity = PURE.const_; // assume strong until something weakens it
 
         /* Evaluate what kind of purity based on the modifiers for the parameters
          */
-    Lloop: foreach (i, fparam; tf.parameterList)
+        foreach (i, fparam; tf.parameterList)
         {
             Type t = fparam.type;
             if (!t)
@@ -4275,33 +4283,11 @@ extern (C++) final class TypeFunction : TypeNext
                 purity = PURE.weak;
                 break;
             }
-            switch (purityOfType((fparam.storageClass & STC.ref_) != 0, t))
-            {
-                case PURE.weak:
-                    purity = PURE.weak;
-                    break Lloop; // since PURE.weak, no need to check further
-
-                case PURE.const_:
-                    purity = PURE.const_;
-                    continue;
-
-                case PURE.strong:
-                    continue;
-
-                default:
-                    assert(0);
-            }
+            const pref = (fparam.storageClass & STC.ref_) != 0;
+            if (mutabilityOfType(pref, t) == 0)
+                purity = PURE.weak;
         }
 
-        if (purity > PURE.weak && tf.nextOf())
-        {
-            /* Adjust purity based on mutability of return type.
-             * https://issues.dlang.org/show_bug.cgi?id=15862
-             */
-            const purity2 = purityOfType(tf.isref, tf.nextOf());
-            if (purity2 < purity)
-                purity = purity2;
-        }
         tf.purity = purity;
     }
 
@@ -6306,10 +6292,7 @@ extern (C++) final class TypeClass : Type
 
     extern (D) MATCH implicitConvToWithoutAliasThis(Type to)
     {
-        MATCH m = constConv(to);
-        if (m > MATCH.nomatch)
-            return m;
-
+        // Run semantic before checking whether class is convertible
         ClassDeclaration cdto = to.isClassHandle();
         if (cdto)
         {
@@ -6318,11 +6301,15 @@ extern (C++) final class TypeClass : Type
                 cdto.dsymbolSemantic(null);
             if (sym.semanticRun < PASS.semanticdone && !sym.isBaseInfoComplete())
                 sym.dsymbolSemantic(null);
-            if (cdto.isBaseOf(sym, null) && MODimplicitConv(mod, to.mod))
-            {
-                //printf("'to' is base\n");
-                return MATCH.convert;
-            }
+        }
+        MATCH m = constConv(to);
+        if (m > MATCH.nomatch)
+            return m;
+
+        if (cdto && cdto.isBaseOf(sym, null) && MODimplicitConv(mod, to.mod))
+        {
+            //printf("'to' is base\n");
+            return MATCH.convert;
         }
         return MATCH.nomatch;
     }
@@ -6373,6 +6360,9 @@ extern (C++) final class TypeClass : Type
 
     override MOD deduceWild(Type t, bool isRef)
     {
+        // If sym is forward referenced:
+        if (sym.semanticRun < PASS.semanticdone && !sym.isBaseInfoComplete())
+            sym.dsymbolSemantic(null);
         ClassDeclaration cd = t.isClassHandle();
         if (cd && (sym == cd || cd.isBaseOf(sym, null)))
             return Type.deduceWild(t, isRef);
@@ -6760,19 +6750,21 @@ extern (C++) final class TypeTag : Type
     Loc loc;                /// location of declaration
     TOK tok;                /// TOK.struct_, TOK.union_, TOK.enum_
     Identifier id;          /// tag name identifier
+    Type base;              /// base type for enums otherwise null
     Dsymbols* members;      /// members of struct, null if none
 
     Type resolved;          /// type after semantic() in case there are more others
                             /// pointing to this instance, which can happen with
                             ///   struct S { int a; } s1, *s2;
 
-    extern (D) this(const ref Loc loc, TOK tok, Identifier id, Dsymbols* members)
+    extern (D) this(const ref Loc loc, TOK tok, Identifier id, Type base, Dsymbols* members)
     {
         //printf("TypeTag %p\n", this);
         super(Ttag);
         this.loc = loc;
         this.tok = tok;
         this.id = id;
+        this.base = base;
         this.members = members;
     }
 
diff --git a/gcc/d/dmd/mtype.h b/gcc/d/dmd/mtype.h
index fde5027e8b8..cb6023696ee 100644
--- a/gcc/d/dmd/mtype.h
+++ b/gcc/d/dmd/mtype.h
@@ -553,7 +553,6 @@ enum class PURE : unsigned char
     fwdref = 1,     // it's pure, but not known which level yet
     weak = 2,       // no mutable globals are read or written
     const_ = 3,     // parameters are values or const
-    strong = 4      // parameters are values or immutable
 };
 
 class Parameter : public ASTNode
diff --git a/gcc/d/dmd/nogc.d b/gcc/d/dmd/nogc.d
index ed3f8322708..f25e779a689 100644
--- a/gcc/d/dmd/nogc.d
+++ b/gcc/d/dmd/nogc.d
@@ -71,6 +71,7 @@ public:
         if (!e.f)
             return;
 
+        // Treat lowered hook calls as their original expressions.
         auto fd = stripHookTraceImpl(e.f);
         if (fd.ident == Id._d_arraysetlengthT)
         {
diff --git a/gcc/d/dmd/nspace.d b/gcc/d/dmd/nspace.d
index 29f920aaa4c..40f2676d88f 100644
--- a/gcc/d/dmd/nspace.d
+++ b/gcc/d/dmd/nspace.d
@@ -48,6 +48,7 @@ module dmd.nspace;
 
 import dmd.aggregate;
 import dmd.arraytypes;
+import dmd.astenums;
 import dmd.dscope;
 import dmd.dsymbol;
 import dmd.dsymbolsem;
diff --git a/gcc/d/dmd/objc.d b/gcc/d/dmd/objc.d
index 6d283e17cc6..9e92212ada1 100644
--- a/gcc/d/dmd/objc.d
+++ b/gcc/d/dmd/objc.d
@@ -818,64 +818,6 @@ extern(C++) private final class Supported : Objc
         expression.errorSupplemental("`tupleof` is not available for members " ~
             "of Objective-C classes. Please use the Objective-C runtime instead");
     }
-
-extern(D) private:
-
-    /**
-     * Returns `true` if the given symbol is a symbol declared in
-     * `core.attribute` and has the given identifier.
-     *
-     * This is used to determine if a symbol is a UDA declared in
-     * `core.attribute`.
-     *
-     * Params:
-     *  sd = the symbol to check
-     *  ident = the name of the expected UDA
-     */
-    bool isCoreUda(ScopeDsymbol sd, Identifier ident) const
-    {
-        if (sd.ident != ident || !sd.parent)
-            return false;
-
-        auto _module = sd.parent.isModule();
-        return _module && _module.isCoreModule(Id.attribute);
-    }
-
-    /**
-     * Iterates the UDAs attached to the given function declaration.
-     *
-     * If `dg` returns `!= 0`, it will stop the iteration and return that
-     * value, otherwise it will return 0.
-     *
-     * Params:
-     *  fd = the function declaration to get the UDAs from
-     *  dg = called once for each UDA. If `dg` returns `!= 0`, it will stop the
-     *      iteration and return that value, otherwise it will return `0`.
-     */
-    int foreachUda(FuncDeclaration fd, Scope* sc, int delegate(Expression) dg) const
-    {
-        if (!fd.userAttribDecl)
-            return 0;
-
-        auto udas = fd.userAttribDecl.getAttributes();
-        arrayExpressionSemantic(udas, sc, true);
-
-        return udas.each!((uda) {
-            if (!uda.isTupleExp())
-                return 0;
-
-            auto exps = uda.isTupleExp().exps;
-
-            return exps.each!((e) {
-                assert(e);
-
-                if (auto result = dg(e))
-                    return result;
-
-                return 0;
-            });
-        });
-    }
 }
 
 /*
diff --git a/gcc/d/dmd/opover.d b/gcc/d/dmd/opover.d
index c932d043dbc..5d6128b014c 100644
--- a/gcc/d/dmd/opover.d
+++ b/gcc/d/dmd/opover.d
@@ -853,11 +853,11 @@ Expression op_overload(Expression e, Scope* sc, EXP* pop = null)
                         {
                             // Rewrite (e1 op e2) as e2.opfunc(e1)
                             result = build_overload(e.loc, sc, e.e2, e.e1, m.lastf ? m.lastf : s);
+                            // When reversing operands of comparison operators,
+                            // need to reverse the sense of the op
+                            if (pop)
+                                *pop = reverseRelation(e.op);
                         }
-                        // When reversing operands of comparison operators,
-                        // need to reverse the sense of the op
-                        if (pop)
-                            *pop = reverseRelation(e.op);
                         return;
                     }
                 }
@@ -1052,7 +1052,7 @@ Expression op_overload(Expression e, Scope* sc, EXP* pop = null)
                 e.e2 = new DotIdExp(e.loc, e.e2, Id._tupleof);
 
                 auto sc2 = sc.push();
-                sc2.flags = (sc2.flags & ~SCOPE.onlysafeaccess) | SCOPE.noaccesscheck;
+                sc2.flags |= SCOPE.noaccesscheck;
                 result = e.expressionSemantic(sc2);
                 sc2.pop();
 
diff --git a/gcc/d/dmd/optimize.d b/gcc/d/dmd/optimize.d
index 5864fa2af8e..5b4ebd78223 100644
--- a/gcc/d/dmd/optimize.d
+++ b/gcc/d/dmd/optimize.d
@@ -1130,8 +1130,8 @@ Expression Expression_optimize(Expression e, int result, bool keepLvalue)
             const e1Opt = e.e1.toBool();
             if (e.e2.isConst())
             {
-                bool n1 = e1Opt.hasValue(true);
-                bool n2 = e.e2.toBool().hasValue(true);
+                bool n1 = e1Opt.get();
+                bool n2 = e.e2.toBool().get();
                 ret = new IntegerExp(e.loc, oror ? (n1 || n2) : (n1 && n2), e.type);
             }
             else if (e1Opt.hasValue(!oror))
diff --git a/gcc/d/dmd/parse.d b/gcc/d/dmd/parse.d
index 700f3c57921..63afeb22a4b 100644
--- a/gcc/d/dmd/parse.d
+++ b/gcc/d/dmd/parse.d
@@ -128,6 +128,7 @@ immutable PREC[EXP.max + 1] precedence =
     EXP.new_ : PREC.unary,
     EXP.newAnonymousClass : PREC.unary,
     EXP.cast_ : PREC.unary,
+    EXP.throw_ : PREC.unary,
 
     EXP.vector : PREC.unary,
     EXP.pow : PREC.pow,
@@ -443,6 +444,13 @@ class Parser(AST) : Lexer
         }
 
         decldefs = parseDeclDefs(0, &lastDecl);
+
+        if (token.value == TOK.rightCurly)
+        {
+            error(token.loc, "unmatched closing brace");
+            goto Lerr;
+        }
+
         if (token.value != TOK.endOfFile)
         {
             error(token.loc, "unrecognized declaration");
@@ -643,7 +651,43 @@ class Parser(AST) : Lexer
                 goto Lerror;
 
             case TOK.unittest_:
-                if (global.params.useUnitTests || global.params.doDocComments || global.params.doHdrGeneration)
+                /**
+                 * Ignore unittests in non-root modules.
+                 *
+                 * This mainly means that unittests *inside templates* are only
+                 * ever instantiated if the module lexically declaring the
+                 * template is one of the root modules.
+                 *
+                 * E.g., compiling some project with `-unittest` does NOT
+                 * compile and later run any unittests in instantiations of
+                 * templates declared in other libraries.
+                 *
+                 * Declaring unittests *inside* templates is considered an anti-
+                 * pattern. In almost all cases, the unittests don't depend on
+                 * the template parameters, but instantiate the template with
+                 * fixed arguments (e.g., Nullable!T unittests instantiating
+                 * Nullable!int), so compiling and running identical tests for
+                 * each template instantiation is hardly desirable.
+                 * But adding a unittest right below some function being tested
+                 * is arguably good for locality, so unittests end up inside
+                 * templates.
+                 * To make sure a template's unittests are run, it should be
+                 * instantiated in the same module, e.g., some module-level
+                 * unittest.
+                 *
+                 * Another reason for ignoring unittests in templates from non-
+                 * root modules is for template codegen culling via
+                 * TemplateInstance.needsCodegen(). If the compiler decides not
+                 * to emit some Nullable!bool because there's an existing
+                 * instantiation in some non-root module, it has no idea whether
+                 * that module was compiled with -unittest too, and so whether
+                 * Nullable!int (instantiated in some unittest inside the
+                 * Nullable template) can be culled too. By ignoring unittests
+                 * in non-root modules, the compiler won't consider any
+                 * template instantiations in these unittests as candidates for
+                 * further codegen culling.
+                 */
+                if (mod.isRoot() && (global.params.useUnitTests || global.params.doDocComments || global.params.doHdrGeneration))
                 {
                     s = parseUnitTest(pAttrs);
                     if (*pLastDecl)
@@ -1530,6 +1574,8 @@ class Parser(AST) : Lexer
 
             case TOK.return_:
                 stc = STC.return_;
+                if (peekNext() == TOK.scope_)
+                    stc |= STC.returnScope;     // recognize `return scope`
                 break;
 
             case TOK.scope_:
@@ -2880,7 +2926,7 @@ class Parser(AST) : Lexer
         StorageClass varargsStc;
 
         // Attributes allowed for ...
-        enum VarArgsStc = STC.const_ | STC.immutable_ | STC.shared_ | STC.scope_ | STC.return_;
+        enum VarArgsStc = STC.const_ | STC.immutable_ | STC.shared_ | STC.scope_ | STC.return_ | STC.returnScope;
 
         check(TOK.leftParenthesis);
         while (1)
@@ -2988,6 +3034,8 @@ class Parser(AST) : Lexer
 
                 case TOK.return_:
                     stc = STC.return_;
+                    if (peekNext() == TOK.scope_)
+                        stc |= STC.returnScope;
                     goto L2;
                 L2:
                     storageClass = appendStorageClass(storageClass, stc);
@@ -3491,7 +3539,7 @@ class Parser(AST) : Lexer
         return baseclasses;
     }
 
-    private AST.Dsymbols* parseImport()
+    AST.Dsymbols* parseImport()
     {
         auto decldefs = new AST.Dsymbols();
         Identifier aliasid = null;
@@ -4453,7 +4501,6 @@ class Parser(AST) : Lexer
     private AST.Dsymbols* parseDeclarations(bool autodecl, PrefixAttributes!AST* pAttrs, const(char)* comment)
     {
         StorageClass storage_class = STC.undefined_;
-        TOK tok = TOK.reserved;
         LINK link = linkage;
         Loc linkloc = this.linkLoc;
         bool setAlignment = false;
@@ -4464,245 +4511,22 @@ class Parser(AST) : Lexer
         if (!comment)
             comment = token.blockComment.ptr;
 
-        /* Look for AliasAssignment:
-         *   identifier = type;
+        /* Look for AliasReassignment
          */
         if (token.value == TOK.identifier && peekNext() == TOK.assign)
-        {
-            const loc = token.loc;
-            auto ident = token.ident;
-            nextToken();
-            nextToken();        // advance past =
-            auto t = parseType();
-            AST.Dsymbol s = new AST.AliasAssign(loc, ident, t, null);
-            check(TOK.semicolon);
-            addComment(s, comment);
-            auto a = new AST.Dsymbols();
-            a.push(s);
-            return a;
-        }
+            return parseAliasReassignment(comment);
 
+        /* Declarations that start with `alias`
+         */
+        bool isAliasDeclaration = false;
         if (token.value == TOK.alias_)
         {
-            const loc = token.loc;
-            tok = token.value;
-            nextToken();
-
-            /* Look for:
-             *   alias identifier this;
-             */
-            if (token.value == TOK.identifier && peekNext() == TOK.this_)
-            {
-                auto s = new AST.AliasThis(loc, token.ident);
-                nextToken();
-                check(TOK.this_);
-                check(TOK.semicolon);
-                auto a = new AST.Dsymbols();
-                a.push(s);
-                addComment(s, comment);
+            if (auto a = parseAliasDeclarations(comment))
                 return a;
-            }
-            version (none)
-            {
-                /* Look for:
-                 *  alias this = identifier;
-                 */
-                if (token.value == TOK.this_ && peekNext() == TOK.assign && peekNext2() == TOK.identifier)
-                {
-                    check(TOK.this_);
-                    check(TOK.assign);
-                    auto s = new AliasThis(loc, token.ident);
-                    nextToken();
-                    check(TOK.semicolon);
-                    auto a = new Dsymbols();
-                    a.push(s);
-                    addComment(s, comment);
-                    return a;
-                }
-            }
-            /* Look for:
-             *  alias identifier = type;
-             *  alias identifier(...) = type;
+            /* Handle these later:
+             *   alias StorageClasses type ident;
              */
-            if (token.value == TOK.identifier && hasOptionalParensThen(peek(&token), TOK.assign))
-            {
-                auto a = new AST.Dsymbols();
-                while (1)
-                {
-                    auto ident = token.ident;
-                    nextToken();
-                    AST.TemplateParameters* tpl = null;
-                    if (token.value == TOK.leftParenthesis)
-                        tpl = parseTemplateParameterList();
-                    check(TOK.assign);
-
-                    bool hasParsedAttributes;
-                    void parseAttributes()
-                    {
-                        if (hasParsedAttributes) // only parse once
-                            return;
-                        hasParsedAttributes = true;
-                        udas = null;
-                        storage_class = STC.undefined_;
-                        link = linkage;
-                        linkloc = this.linkLoc;
-                        setAlignment = false;
-                        ealign = null;
-                        parseStorageClasses(storage_class, link, setAlignment, ealign, udas, linkloc);
-                    }
-
-                    if (token.value == TOK.at)
-                        parseAttributes;
-
-                    AST.Declaration v;
-                    AST.Dsymbol s;
-
-                    // try to parse function type:
-                    // TypeCtors? BasicType ( Parameters ) MemberFunctionAttributes
-                    bool attributesAppended;
-                    const StorageClass funcStc = parseTypeCtor();
-                    Token* tlu = &token;
-                    Token* tk;
-                    if (token.value != TOK.function_ &&
-                        token.value != TOK.delegate_ &&
-                        isBasicType(&tlu) && tlu &&
-                        tlu.value == TOK.leftParenthesis)
-                    {
-                        AST.Type tret = parseBasicType();
-                        auto parameterList = parseParameterList(null);
-
-                        parseAttributes();
-                        if (udas)
-                            error("user-defined attributes not allowed for `alias` declarations");
-
-                        attributesAppended = true;
-                        storage_class = appendStorageClass(storage_class, funcStc);
-                        AST.Type tf = new AST.TypeFunction(parameterList, tret, link, storage_class);
-                        v = new AST.AliasDeclaration(loc, ident, tf);
-                    }
-                    else if (token.value == TOK.function_ ||
-                        token.value == TOK.delegate_ ||
-                        token.value == TOK.leftParenthesis &&
-                            skipAttributes(peekPastParen(&token), &tk) &&
-                            (tk.value == TOK.goesTo || tk.value == TOK.leftCurly) ||
-                        token.value == TOK.leftCurly ||
-                        token.value == TOK.identifier && peekNext() == TOK.goesTo ||
-                        token.value == TOK.ref_ && peekNext() == TOK.leftParenthesis &&
-                            skipAttributes(peekPastParen(peek(&token)), &tk) &&
-                            (tk.value == TOK.goesTo || tk.value == TOK.leftCurly)
-                       )
-                    {
-                        // function (parameters) { statements... }
-                        // delegate (parameters) { statements... }
-                        // (parameters) { statements... }
-                        // (parameters) => expression
-                        // { statements... }
-                        // identifier => expression
-                        // ref (parameters) { statements... }
-                        // ref (parameters) => expression
-
-                        s = parseFunctionLiteral();
-
-                        if (udas !is null)
-                        {
-                            if (storage_class != 0)
-                                error("Cannot put a storage-class in an alias declaration.");
-                            // parseAttributes shouldn't have set these variables
-                            assert(link == linkage && !setAlignment && ealign is null);
-                            auto tpl_ = cast(AST.TemplateDeclaration) s;
-                            assert(tpl_ !is null && tpl_.members.dim == 1);
-                            auto fd = cast(AST.FuncLiteralDeclaration) (*tpl_.members)[0];
-                            auto tf = cast(AST.TypeFunction) fd.type;
-                            assert(tf.parameterList.parameters.dim > 0);
-                            auto as = new AST.Dsymbols();
-                            (*tf.parameterList.parameters)[0].userAttribDecl = new AST.UserAttributeDeclaration(udas, as);
-                        }
-
-                        v = new AST.AliasDeclaration(loc, ident, s);
-                    }
-                    else
-                    {
-                        parseAttributes();
-                        // type
-                        if (udas)
-                            error("user-defined attributes not allowed for `%s` declarations", Token.toChars(tok));
-
-                        auto t = parseType();
-
-                        // Disallow meaningless storage classes on type aliases
-                        if (storage_class)
-                        {
-                            // Don't raise errors for STC that are part of a function/delegate type, e.g.
-                            // `alias F = ref pure nothrow @nogc @safe int function();`
-                            auto tp = t.isTypePointer;
-                            const isFuncType = (tp && tp.next.isTypeFunction) || t.isTypeDelegate;
-                            const remStc = isFuncType ? (storage_class & ~STC.FUNCATTR) : storage_class;
-
-                            if (remStc)
-                            {
-                                OutBuffer buf;
-                                AST.stcToBuffer(&buf, remStc);
-                                // @@@DEPRECATED_2.093@@@
-                                // Deprecated in 2020-07, can be made an error in 2.103
-                                deprecation("storage class `%s` has no effect in type aliases", buf.peekChars());
-                            }
-                        }
-
-                        v = new AST.AliasDeclaration(loc, ident, t);
-                    }
-                    if (!attributesAppended)
-                        storage_class = appendStorageClass(storage_class, funcStc);
-                    v.storage_class = storage_class;
-
-                    s = v;
-                    if (tpl)
-                    {
-                        auto a2 = new AST.Dsymbols();
-                        a2.push(s);
-                        auto tempdecl = new AST.TemplateDeclaration(loc, ident, tpl, null, a2);
-                        s = tempdecl;
-                    }
-                    if (link != linkage)
-                    {
-                        auto a2 = new AST.Dsymbols();
-                        a2.push(s);
-                        s = new AST.LinkDeclaration(linkloc, link, a2);
-                    }
-                    a.push(s);
-
-                    switch (token.value)
-                    {
-                    case TOK.semicolon:
-                        nextToken();
-                        addComment(s, comment);
-                        break;
-
-                    case TOK.comma:
-                        nextToken();
-                        addComment(s, comment);
-                        if (token.value != TOK.identifier)
-                        {
-                            error("identifier expected following comma, not `%s`", token.toChars());
-                            break;
-                        }
-                        if (peekNext() != TOK.assign && peekNext() != TOK.leftParenthesis)
-                        {
-                            error("`=` expected following identifier");
-                            nextToken();
-                            break;
-                        }
-                        continue;
-
-                    default:
-                        error("semicolon expected to close `%s` declaration", Token.toChars(tok));
-                        break;
-                    }
-                    break;
-                }
-                return a;
-            }
-
-            // alias StorageClasses type ident;
+            isAliasDeclaration = true;
         }
 
         AST.Type ts;
@@ -4839,7 +4663,7 @@ class Parser(AST) : Lexer
             else if (!isThis && (t != AST.Type.terror))
                 error("no identifier for declarator `%s`", t.toChars());
 
-            if (tok == TOK.alias_)
+            if (isAliasDeclaration)
             {
                 AST.Declaration v;
                 AST.Initializer _init = null;
@@ -4852,7 +4676,7 @@ class Parser(AST) : Lexer
                  */
 
                 if (udas)
-                    error("user-defined attributes not allowed for `%s` declarations", Token.toChars(tok));
+                    error("user-defined attributes not allowed for `alias` declarations");
 
                 if (token.value == TOK.assign)
                 {
@@ -4901,7 +4725,7 @@ class Parser(AST) : Lexer
                     continue;
 
                 default:
-                    error("semicolon expected to close `%s` declaration", Token.toChars(tok));
+                    error("semicolon expected to close `alias` declaration");
                     break;
                 }
             }
@@ -5018,7 +4842,15 @@ class Parser(AST) : Lexer
                     continue;
 
                 default:
-                    error("semicolon expected, not `%s`", token.toChars());
+                    if (loc.linnum != token.loc.linnum)
+                    {
+                        error("semicolon needed to end declaration of `%s`, instead of `%s`", v.toChars(), token.toChars());
+                        errorSupplemental(loc, "`%s` declared here", v.toChars());
+                    }
+                    else
+                    {
+                        error("semicolon needed to end declaration of `%s` instead of `%s`", v.toChars(), token.toChars());
+                    }
                     break;
                 }
             }
@@ -5027,6 +4859,271 @@ class Parser(AST) : Lexer
         return a;
     }
 
+    /********************************
+     * Parse AliasReassignment:
+     *   identifier = type;
+     * Parser is sitting on the identifier.
+     * https://dlang.org/spec/declaration.html#alias-reassignment
+     * Params:
+     *  comment = if not null, comment to attach to symbol
+     * Returns:
+     *  array of symbols
+     */
+    private AST.Dsymbols* parseAliasReassignment(const(char)* comment)
+    {
+        const loc = token.loc;
+        auto ident = token.ident;
+        nextToken();
+        nextToken();        // advance past =
+        auto t = parseType();
+        AST.Dsymbol s = new AST.AliasAssign(loc, ident, t, null);
+        check(TOK.semicolon);
+        addComment(s, comment);
+        auto a = new AST.Dsymbols();
+        a.push(s);
+        return a;
+    }
+
+    /********************************
+     * Parse declarations that start with `alias`
+     * Parser is sitting on the `alias`.
+     * https://dlang.org/spec/declaration.html#alias
+     * Params:
+     *  comment = if not null, comment to attach to symbol
+     * Returns:
+     *  array of symbols
+     */
+    private AST.Dsymbols* parseAliasDeclarations(const(char)* comment)
+    {
+        const loc = token.loc;
+        nextToken();
+        Loc linkloc = this.linkLoc;
+        AST.Expressions* udas;
+        LINK link = linkage;
+        StorageClass storage_class = STC.undefined_;
+        AST.Expression ealign;
+        bool setAlignment = false;
+
+        /* Look for:
+         *   alias Identifier this;
+         * https://dlang.org/spec/class.html#alias-this
+         */
+        if (token.value == TOK.identifier && peekNext() == TOK.this_)
+        {
+            auto s = new AST.AliasThis(loc, token.ident);
+            nextToken();
+            check(TOK.this_);
+            check(TOK.semicolon);
+            auto a = new AST.Dsymbols();
+            a.push(s);
+            addComment(s, comment);
+            return a;
+        }
+        version (none)
+        {
+            /* Look for:
+             *  alias this = identifier;
+             */
+            if (token.value == TOK.this_ && peekNext() == TOK.assign && peekNext2() == TOK.identifier)
+            {
+                check(TOK.this_);
+                check(TOK.assign);
+                auto s = new AliasThis(loc, token.ident);
+                nextToken();
+                check(TOK.semicolon);
+                auto a = new Dsymbols();
+                a.push(s);
+                addComment(s, comment);
+                return a;
+            }
+        }
+        /* Look for:
+         *  alias identifier = type;
+         *  alias identifier(...) = type;
+         * https://dlang.org/spec/declaration.html#alias
+         */
+        if (token.value == TOK.identifier && hasOptionalParensThen(peek(&token), TOK.assign))
+        {
+            auto a = new AST.Dsymbols();
+            while (1)
+            {
+                auto ident = token.ident;
+                nextToken();
+                AST.TemplateParameters* tpl = null;
+                if (token.value == TOK.leftParenthesis)
+                    tpl = parseTemplateParameterList();
+                check(TOK.assign);
+
+                bool hasParsedAttributes;
+                void parseAttributes()
+                {
+                    if (hasParsedAttributes) // only parse once
+                        return;
+                    hasParsedAttributes = true;
+                    udas = null;
+                    storage_class = STC.undefined_;
+                    link = linkage;
+                    linkloc = this.linkLoc;
+                    setAlignment = false;
+                    ealign = null;
+                    parseStorageClasses(storage_class, link, setAlignment, ealign, udas, linkloc);
+                }
+
+                if (token.value == TOK.at)
+                    parseAttributes;
+
+                AST.Declaration v;
+                AST.Dsymbol s;
+
+                // try to parse function type:
+                // TypeCtors? BasicType ( Parameters ) MemberFunctionAttributes
+                bool attributesAppended;
+                const StorageClass funcStc = parseTypeCtor();
+                Token* tlu = &token;
+                Token* tk;
+                if (token.value != TOK.function_ &&
+                    token.value != TOK.delegate_ &&
+                    isBasicType(&tlu) && tlu &&
+                    tlu.value == TOK.leftParenthesis)
+                {
+                    AST.Type tret = parseBasicType();
+                    auto parameterList = parseParameterList(null);
+
+                    parseAttributes();
+                    if (udas)
+                        error("user-defined attributes not allowed for `alias` declarations");
+
+                    attributesAppended = true;
+                    storage_class = appendStorageClass(storage_class, funcStc);
+                    AST.Type tf = new AST.TypeFunction(parameterList, tret, link, storage_class);
+                    v = new AST.AliasDeclaration(loc, ident, tf);
+                }
+                else if (token.value == TOK.function_ ||
+                    token.value == TOK.delegate_ ||
+                    token.value == TOK.leftParenthesis &&
+                        skipAttributes(peekPastParen(&token), &tk) &&
+                        (tk.value == TOK.goesTo || tk.value == TOK.leftCurly) ||
+                    token.value == TOK.leftCurly ||
+                    token.value == TOK.identifier && peekNext() == TOK.goesTo ||
+                    token.value == TOK.ref_ && peekNext() == TOK.leftParenthesis &&
+                        skipAttributes(peekPastParen(peek(&token)), &tk) &&
+                        (tk.value == TOK.goesTo || tk.value == TOK.leftCurly)
+                   )
+                {
+                    // function (parameters) { statements... }
+                    // delegate (parameters) { statements... }
+                    // (parameters) { statements... }
+                    // (parameters) => expression
+                    // { statements... }
+                    // identifier => expression
+                    // ref (parameters) { statements... }
+                    // ref (parameters) => expression
+
+                    s = parseFunctionLiteral();
+
+                    if (udas !is null)
+                    {
+                        if (storage_class != 0)
+                            error("Cannot put a storage-class in an alias declaration.");
+                        // parseAttributes shouldn't have set these variables
+                        assert(link == linkage && !setAlignment && ealign is null);
+                        auto tpl_ = cast(AST.TemplateDeclaration) s;
+                        assert(tpl_ !is null && tpl_.members.dim == 1);
+                        auto fd = cast(AST.FuncLiteralDeclaration) (*tpl_.members)[0];
+                        auto tf = cast(AST.TypeFunction) fd.type;
+                        assert(tf.parameterList.parameters.dim > 0);
+                        auto as = new AST.Dsymbols();
+                        (*tf.parameterList.parameters)[0].userAttribDecl = new AST.UserAttributeDeclaration(udas, as);
+                    }
+
+                    v = new AST.AliasDeclaration(loc, ident, s);
+                }
+                else
+                {
+                    parseAttributes();
+                    // type
+                    if (udas)
+                        error("user-defined attributes not allowed for alias declarations");
+
+                    auto t = parseType();
+
+                    // Disallow meaningless storage classes on type aliases
+                    if (storage_class)
+                    {
+                        // Don't raise errors for STC that are part of a function/delegate type, e.g.
+                        // `alias F = ref pure nothrow @nogc @safe int function();`
+                        auto tp = t.isTypePointer;
+                        const isFuncType = (tp && tp.next.isTypeFunction) || t.isTypeDelegate;
+                        const remStc = isFuncType ? (storage_class & ~STC.FUNCATTR) : storage_class;
+
+                        if (remStc)
+                        {
+                            OutBuffer buf;
+                            AST.stcToBuffer(&buf, remStc);
+                            // @@@DEPRECATED_2.093@@@
+                            // Deprecated in 2020-07, can be made an error in 2.103
+                            deprecation("storage class `%s` has no effect in type aliases", buf.peekChars());
+                        }
+                    }
+
+                    v = new AST.AliasDeclaration(loc, ident, t);
+                }
+                if (!attributesAppended)
+                    storage_class = appendStorageClass(storage_class, funcStc);
+                v.storage_class = storage_class;
+
+                s = v;
+                if (tpl)
+                {
+                    auto a2 = new AST.Dsymbols();
+                    a2.push(s);
+                    auto tempdecl = new AST.TemplateDeclaration(loc, ident, tpl, null, a2);
+                    s = tempdecl;
+                }
+                if (link != linkage)
+                {
+                    auto a2 = new AST.Dsymbols();
+                    a2.push(s);
+                    s = new AST.LinkDeclaration(linkloc, link, a2);
+                }
+                a.push(s);
+
+                switch (token.value)
+                {
+                case TOK.semicolon:
+                    nextToken();
+                    addComment(s, comment);
+                    break;
+
+                case TOK.comma:
+                    nextToken();
+                    addComment(s, comment);
+                    if (token.value != TOK.identifier)
+                    {
+                        error("identifier expected following comma, not `%s`", token.toChars());
+                        break;
+                    }
+                    if (peekNext() != TOK.assign && peekNext() != TOK.leftParenthesis)
+                    {
+                        error("`=` expected following identifier");
+                        nextToken();
+                        break;
+                    }
+                    continue;
+
+                default:
+                    error("semicolon expected to close `alias` declaration");
+                    break;
+                }
+                break;
+            }
+            return a;
+        }
+
+        // alias StorageClasses type ident;
+        return null;
+    }
+
     private AST.Dsymbol parseFunctionLiteral()
     {
         const loc = token.loc;
@@ -5390,6 +5487,7 @@ class Parser(AST) : Lexer
         check(TOK.leftParenthesis);
 
         auto parameters = new AST.Parameters();
+        Identifier lastai;
         while (1)
         {
             Identifier ai = null;
@@ -5465,8 +5563,9 @@ class Parser(AST) : Lexer
             if (token.value == TOK.identifier)
             {
                 const tv = peekNext();
-                if (tv == TOK.comma || tv == TOK.semicolon)
+                if (tv == TOK.comma || tv == TOK.semicolon || tv == TOK.rightParenthesis)
                 {
+                    lastai = token.ident;
                     ai = token.ident;
                     at = null; // infer argument type
                     nextToken();
@@ -5486,7 +5585,17 @@ class Parser(AST) : Lexer
             }
             break;
         }
-        check(TOK.semicolon);
+        if (token.value != TOK.semicolon)
+        {
+            error("missing `; expression` before `)` of `foreach`");
+            nextToken();
+            if (lastai && parameters.length >= 2)
+            {
+                errorSupplemental(loc, "perhaps the `;` goes before `%s`", lastai.toChars());
+            }
+            return null;
+        }
+        nextToken();
 
         AST.Expression aggr = parseExpression();
         if (token.value == TOK.slice && parameters.dim == 1)
@@ -8473,6 +8582,7 @@ LagainStc:
                 e = new AST.FuncExp(loc, s);
                 break;
             }
+
         default:
             error("expression expected, not `%s`", token.toChars());
         Lerr:
@@ -8766,6 +8876,17 @@ LagainStc:
                 e = parsePostExp(e);
                 break;
             }
+        case TOK.throw_:
+            {
+                nextToken();
+                // Deviation from the DIP:
+                // Parse AssignExpression instead of Expression to avoid conflicts for comma
+                // separated lists, e.g. function arguments
+                AST.Expression exp = parseAssignExp();
+                e = new AST.ThrowExp(loc, exp);
+                break;
+            }
+
         default:
             e = parsePrimaryExp();
             e = parsePostExp(e);
diff --git a/gcc/d/dmd/parsetimevisitor.d b/gcc/d/dmd/parsetimevisitor.d
index d3e30861a8a..7d5e19da9ee 100644
--- a/gcc/d/dmd/parsetimevisitor.d
+++ b/gcc/d/dmd/parsetimevisitor.d
@@ -220,6 +220,7 @@ public:
     void visit(AST.CallExp e) { visit(cast(AST.UnaExp)e); }
     void visit(AST.DotIdExp e) { visit(cast(AST.UnaExp)e); }
     void visit(AST.AssertExp e) { visit(cast(AST.UnaExp)e); }
+    void visit(AST.ThrowExp e) { visit(cast(AST.UnaExp)e); }
     void visit(AST.ImportExp e) { visit(cast(AST.UnaExp)e); }
     void visit(AST.DotTemplateInstanceExp e) { visit(cast(AST.UnaExp)e); }
     void visit(AST.ArrayExp e) { visit(cast(AST.UnaExp)e); }
diff --git a/gcc/d/dmd/root/README.md b/gcc/d/dmd/root/README.md
index b393c123da1..464f3389127 100644
--- a/gcc/d/dmd/root/README.md
+++ b/gcc/d/dmd/root/README.md
@@ -13,6 +13,7 @@
 | [hash.d](https://github.com/dlang/dmd/blob/master/src/dmd/root/hash.d)               | Calculate a hash for a byte array                                                          |
 | [longdouble.d](https://github.com/dlang/dmd/blob/master/src/dmd/root/longdouble.d)   | 80-bit floating point number implementation in case they are not natively supported        |
 | [man.d](https://github.com/dlang/dmd/blob/master/src/dmd/root/man.d)                 | Opens an online manual page                                                                |
+| [optional.d](https://github.com/dlang/dmd/blob/master/src/dmd/root/optional.d)       | Implementation of an 'Optional' type                                                       |
 | [port.d](https://github.com/dlang/dmd/blob/master/src/dmd/root/port.d)               | Portable routines for functions that have different implementations on different platforms |
 | [region.d](https://github.com/dlang/dmd/blob/master/src/dmd/root/region.d)           | A region allocator                                                                         |
 | [response.d](https://github.com/dlang/dmd/blob/master/src/dmd/root/response.d)       | Parse command line arguments from response files                                           |
diff --git a/gcc/d/dmd/root/optional.d b/gcc/d/dmd/root/optional.d
index bb8150f904b..f2f7389efd2 100644
--- a/gcc/d/dmd/root/optional.d
+++ b/gcc/d/dmd/root/optional.d
@@ -1,5 +1,5 @@
 /**
- * Optional implementation.
+ * Implementation of an 'Optional' type
  *
  * Copyright:   Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
  * Authors:     $(LINK2 https://www.digitalmars.com, Walter Bright)
diff --git a/gcc/d/dmd/sideeffect.d b/gcc/d/dmd/sideeffect.d
index d36504948c0..5691f3b75b6 100644
--- a/gcc/d/dmd/sideeffect.d
+++ b/gcc/d/dmd/sideeffect.d
@@ -94,8 +94,9 @@ extern (C++) bool hasSideEffect(Expression e, bool assumeImpureCalls = false)
  * Determine if the call of f, or function type or delegate type t1, has any side effects.
  * Returns:
  *      0   has any side effects
- *      1   nothrow + constant purity
- *      2   nothrow + strong purity
+ *      1   nothrow + strongly pure
+ *      2   nothrow + strongly pure + only immutable indirections in the return
+ *          type
  */
 int callSideEffectLevel(FuncDeclaration f)
 {
@@ -106,15 +107,18 @@ int callSideEffectLevel(FuncDeclaration f)
         return 0;
     assert(f.type.ty == Tfunction);
     TypeFunction tf = cast(TypeFunction)f.type;
-    if (tf.isnothrow)
+    if (!tf.isnothrow)
+        return 0;
+    final switch (f.isPure())
     {
-        PURE purity = f.isPure();
-        if (purity == PURE.strong)
-            return 2;
-        if (purity == PURE.const_)
-            return 1;
+    case PURE.impure:
+    case PURE.fwdref:
+    case PURE.weak:
+        return 0;
+
+    case PURE.const_:
+        return mutabilityOfType(tf.isref, tf.next) == 2 ? 2 : 1;
     }
-    return 0;
 }
 
 int callSideEffectLevel(Type t)
@@ -141,10 +145,9 @@ int callSideEffectLevel(Type t)
             purity = PURE.const_;
     }
 
-    if (purity == PURE.strong)
-        return 2;
     if (purity == PURE.const_)
-        return 1;
+        return mutabilityOfType(tf.isref, tf.next) == 2 ? 2 : 1;
+
     return 0;
 }
 
@@ -178,6 +181,7 @@ private bool lambdaHasSideEffect(Expression e, bool assumeImpureCalls = false)
     case EXP.remove:
     case EXP.assert_:
     case EXP.halt:
+    case EXP.throw_:
     case EXP.delete_:
     case EXP.new_:
     case EXP.newAnonymousClass:
diff --git a/gcc/d/dmd/statement.d b/gcc/d/dmd/statement.d
index be568f58135..8b271f8862f 100644
--- a/gcc/d/dmd/statement.d
+++ b/gcc/d/dmd/statement.d
@@ -21,7 +21,6 @@ import dmd.arraytypes;
 import dmd.astenums;
 import dmd.ast_node;
 import dmd.gluelayer;
-import dmd.canthrow;
 import dmd.cond;
 import dmd.dclass;
 import dmd.declaration;
diff --git a/gcc/d/dmd/statement.h b/gcc/d/dmd/statement.h
index dfb65a1847d..66eddd8ab55 100644
--- a/gcc/d/dmd/statement.h
+++ b/gcc/d/dmd/statement.h
@@ -45,7 +45,7 @@ struct code;
 
 /* How a statement exits; this is returned by blockExit()
  */
-enum BE
+enum BE : int32_t
 {
     BEnone =     0,
     BEfallthru = 1,
diff --git a/gcc/d/dmd/statementsem.d b/gcc/d/dmd/statementsem.d
index faeba11446a..1f7f3e4bc80 100644
--- a/gcc/d/dmd/statementsem.d
+++ b/gcc/d/dmd/statementsem.d
@@ -122,8 +122,10 @@ private LabelStatement checkLabeledLoop(Scope* sc, Statement statement)
  * Returns:
  *  `e` or ErrorExp.
  */
-private Expression checkAssignmentAsCondition(Expression e)
+private Expression checkAssignmentAsCondition(Expression e, Scope* sc)
 {
+    if (sc.flags & SCOPE.Cfile)
+        return e;
     auto ec = lastComma(e);
     if (ec.op == EXP.assign)
     {
@@ -148,7 +150,7 @@ extern(C++) Statement statementSemantic(Statement s, Scope* sc)
     return v.result;
 }
 
-private extern (C++) final class StatementSemanticVisitor : Visitor
+package (dmd) extern (C++) final class StatementSemanticVisitor : Visitor
 {
     alias visit = Visitor.visit;
 
@@ -550,7 +552,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor
             (cast(DotIdExp)ds.condition).noderef = true;
 
         // check in syntax level
-        ds.condition = checkAssignmentAsCondition(ds.condition);
+        ds.condition = checkAssignmentAsCondition(ds.condition, sc);
 
         ds.condition = ds.condition.expressionSemantic(sc);
         ds.condition = resolveProperties(sc, ds.condition);
@@ -623,7 +625,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor
                 (cast(DotIdExp)fs.condition).noderef = true;
 
             // check in syntax level
-            fs.condition = checkAssignmentAsCondition(fs.condition);
+            fs.condition = checkAssignmentAsCondition(fs.condition, sc);
 
             fs.condition = fs.condition.expressionSemantic(sc);
             fs.condition = resolveProperties(sc, fs.condition);
@@ -1867,7 +1869,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor
          */
 
         // check in syntax level
-        ifs.condition = checkAssignmentAsCondition(ifs.condition);
+        ifs.condition = checkAssignmentAsCondition(ifs.condition, sc);
 
         auto sym = new ScopeDsymbol();
         sym.parent = sc.scopesym;
@@ -3732,44 +3734,61 @@ private extern (C++) final class StatementSemanticVisitor : Visitor
          */
 
         //printf("ThrowStatement::semantic()\n");
+        if (throwSemantic(ts.loc, ts.exp, sc))
+            result = ts;
+        else
+            setError();
+
+    }
 
+    /**
+     * Run semantic on `throw <exp>`.
+     *
+     * Params:
+     *   loc = location of the `throw`
+     *   exp = value to be thrown
+     *   sc  = enclosing scope
+     *
+     * Returns: true if the `throw` is valid, or false if an error was found
+     */
+    extern(D) static bool throwSemantic(const ref Loc loc, ref Expression exp, Scope* sc)
+    {
         if (!global.params.useExceptions)
         {
-            ts.error("Cannot use `throw` statements with -betterC");
-            return setError();
+            loc.error("Cannot use `throw` statements with -betterC");
+            return false;
         }
 
         if (!ClassDeclaration.throwable)
         {
-            ts.error("Cannot use `throw` statements because `object.Throwable` was not declared");
-            return setError();
+            loc.error("Cannot use `throw` statements because `object.Throwable` was not declared");
+            return false;
         }
 
-        FuncDeclaration fd = sc.parent.isFuncDeclaration();
-        fd.hasReturnExp |= 2;
+        if (FuncDeclaration fd = sc.parent.isFuncDeclaration())
+            fd.hasReturnExp |= 2;
 
-        if (ts.exp.op == EXP.new_)
+        if (exp.op == EXP.new_)
         {
-            NewExp ne = cast(NewExp)ts.exp;
+            NewExp ne = cast(NewExp) exp;
             ne.thrownew = true;
         }
 
-        ts.exp = ts.exp.expressionSemantic(sc);
-        ts.exp = resolveProperties(sc, ts.exp);
-        ts.exp = checkGC(sc, ts.exp);
-        if (ts.exp.op == EXP.error)
-            return setError();
+        exp = exp.expressionSemantic(sc);
+        exp = resolveProperties(sc, exp);
+        exp = checkGC(sc, exp);
+        if (exp.op == EXP.error)
+            return false;
 
-        checkThrowEscape(sc, ts.exp, false);
+        checkThrowEscape(sc, exp, false);
 
-        ClassDeclaration cd = ts.exp.type.toBasetype().isClassHandle();
+        ClassDeclaration cd = exp.type.toBasetype().isClassHandle();
         if (!cd || ((cd != ClassDeclaration.throwable) && !ClassDeclaration.throwable.isBaseOf(cd, null)))
         {
-            ts.error("can only throw class objects derived from `Throwable`, not type `%s`", ts.exp.type.toChars());
-            return setError();
+            loc.error("can only throw class objects derived from `Throwable`, not type `%s`", exp.type.toChars());
+            return false;
         }
-
-        result = ts;
+        return true;
     }
 
     override void visit(DebugStatement ds)
diff --git a/gcc/d/dmd/staticcond.d b/gcc/d/dmd/staticcond.d
index 6ff166a44e6..0cbdd963afa 100644
--- a/gcc/d/dmd/staticcond.d
+++ b/gcc/d/dmd/staticcond.d
@@ -109,18 +109,16 @@ bool evalStaticCondition(Scope* sc, Expression original, Expression e, out bool
         e = e.ctfeInterpret();
 
         const opt = e.toBool();
-        if (opt.hasValue(true))
-            return true;
-        else if (opt.hasValue(false))
+        if (opt.isEmpty())
         {
-            if (negatives)
-                negatives.push(before);
+            e.error("expression `%s` is not constant", e.toChars());
+            errors = true;
             return false;
         }
 
-        e.error("expression `%s` is not constant", e.toChars());
-        errors = true;
-        return false;
+        if (negatives && !opt.get())
+            negatives.push(before);
+        return opt.get();
     }
     return impl(e);
 }
diff --git a/gcc/d/dmd/target.d b/gcc/d/dmd/target.d
index 619304db927..e95462568af 100644
--- a/gcc/d/dmd/target.d
+++ b/gcc/d/dmd/target.d
@@ -61,8 +61,8 @@ extern (C++) struct Target
     import dmd.dscope : Scope;
     import dmd.expression : Expression;
     import dmd.func : FuncDeclaration;
-    import dmd.globals : LINK, Loc, d_int64;
-    import dmd.astenums : TY;
+    import dmd.globals : Loc, d_int64;
+    import dmd.astenums : LINK, TY;
     import dmd.mtype : Type, TypeFunction, TypeTuple;
     import dmd.root.ctfloat : real_t;
     import dmd.statement : Statement;
@@ -119,7 +119,7 @@ extern (C++) struct Target
     const(char)[] lib_ext;    /// extension for static library files
     const(char)[] dll_ext;    /// extension for dynamic library files
     bool run_noext;           /// allow -run sources without extensions
-    bool mscoff = false;      // for Win32: write MsCoff object files instead of OMF
+    bool omfobj = false;      // for Win32: write OMF object files instead of MsCoff
     /**
      * Values representing all properties for floating point types
      */
@@ -293,6 +293,13 @@ extern (C++) struct Target
      *      `false` if the target backend handles synchronizing monitors.
      */
     extern (C++) bool libraryObjectMonitors(FuncDeclaration fd, Statement fbody);
+
+    /**
+     * Returns true if the target supports `pragma(linkerDirective)`.
+     * Returns:
+     *      `false` if the target does not support `pragma(linkerDirective)`.
+     */
+    extern (C++) bool supportsLinkerDirective() const;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -340,7 +347,7 @@ struct TargetCPP
     import dmd.dsymbol : Dsymbol;
     import dmd.dclass : ClassDeclaration;
     import dmd.func : FuncDeclaration;
-    import dmd.mtype : Parameter, Type;
+    import dmd.mtype : Type;
 
     enum Runtime : ubyte
     {
@@ -354,6 +361,7 @@ struct TargetCPP
     bool reverseOverloads;    /// set if overloaded functions are grouped and in reverse order (such as in dmc and cl)
     bool exceptions;          /// set if catching C++ exceptions is supported
     bool twoDtorInVtable;     /// target C++ ABI puts deleting and non-deleting destructor into vtable
+    bool splitVBasetable;     /// set if C++ ABI uses separate tables for virtual functions and virtual bases
     bool wrapDtorInExternD;   /// set if C++ dtors require a D wrapper to be callable from runtime
     Runtime runtime;          /// vendor of the C++ runtime to link against
 
@@ -398,13 +406,13 @@ struct TargetCPP
 
     /**
      * Get the type that will really be used for passing the given argument
-     * to an `extern(C++)` function.
+     * to an `extern(C++)` function, or `null` if unhandled.
      * Params:
-     *      p = parameter to be passed.
+     *      t = type to be passed.
      * Returns:
-     *      `Type` to use for parameter `p`.
+     *      `Type` to use for type `t`.
      */
-    extern (C++) Type parameterType(Parameter p);
+    extern (C++) Type parameterType(Type t);
 
     /**
      * Checks whether type is a vendor-specific fundamental type.
diff --git a/gcc/d/dmd/target.h b/gcc/d/dmd/target.h
index 9c879de293a..fdae14c9dea 100644
--- a/gcc/d/dmd/target.h
+++ b/gcc/d/dmd/target.h
@@ -20,7 +20,6 @@ class ClassDeclaration;
 class Dsymbol;
 class Expression;
 class FuncDeclaration;
-class Parameter;
 class Statement;
 class Type;
 class TypeTuple;
@@ -92,6 +91,7 @@ struct TargetCPP
     bool reverseOverloads;    // with dmc and cl, overloaded functions are grouped and in reverse order
     bool exceptions;          // set if catching C++ exceptions is supported
     bool twoDtorInVtable;     // target C++ ABI puts deleting and non-deleting destructor into vtable
+    bool splitVBasetable;     // set if C++ ABI uses separate tables for virtual functions and virtual bases
     bool wrapDtorInExternD;   // set if C++ dtors require a D wrapper to be callable from runtime
     Runtime runtime;
 
@@ -99,7 +99,7 @@ struct TargetCPP
     const char *typeInfoMangle(ClassDeclaration *cd);
     const char *thunkMangle(FuncDeclaration *fd, int offset);
     const char *typeMangle(Type *t);
-    Type *parameterType(Parameter *p);
+    Type *parameterType(Type *p);
     bool fundamentalType(const Type *t, bool& isFundamental);
     unsigned derivedClassOffset(ClassDeclaration *baseClass);
 };
@@ -160,7 +160,7 @@ struct Target
     DString lib_ext;    /// extension for static library files
     DString dll_ext;    /// extension for dynamic library files
     bool run_noext;     /// allow -run sources without extensions
-    bool mscoff;        /// for Win32: write COFF object files instead of OMF
+    bool omfobj;        /// for Win32: write OMF object files instead of COFF
 
     template <typename T>
     struct FPTypeProperties
@@ -205,6 +205,7 @@ public:
     Expression *getTargetInfo(const char* name, const Loc& loc);
     bool isCalleeDestroyingArgs(TypeFunction* tf);
     bool libraryObjectMonitors(FuncDeclaration *fd, Statement *fbody);
+    bool supportsLinkerDirective() const;
     void addPredefinedGlobalIdentifiers() const;
 };
 
diff --git a/gcc/d/dmd/template.h b/gcc/d/dmd/template.h
index 95cd349639c..42517f6403c 100644
--- a/gcc/d/dmd/template.h
+++ b/gcc/d/dmd/template.h
@@ -284,6 +284,7 @@ public:
     Identifier *getIdent();
     hash_t toHash();
 
+    bool isDiscardable();
     bool needsCodegen();
 
     TemplateInstance *isTemplateInstance() { return this; }
diff --git a/gcc/d/dmd/tokens.d b/gcc/d/dmd/tokens.d
index 5830dbbf943..20b8711a1cf 100644
--- a/gcc/d/dmd/tokens.d
+++ b/gcc/d/dmd/tokens.d
@@ -278,6 +278,7 @@ enum TOK : ubyte
     _Thread_local,
 
     // C only extended keywords
+    _import,
     __cdecl,
     __declspec,
     __attribute__,
@@ -585,6 +586,7 @@ private immutable TOK[] keywords =
     TOK._Thread_local,
 
     // C only extended keywords
+    TOK._import,
     TOK.__cdecl,
     TOK.__declspec,
     TOK.__attribute__,
@@ -615,7 +617,7 @@ static immutable TOK[TOK.max + 1] Ckeywords =
                        restrict, return_, int16, signed, sizeof_, static_, struct_, switch_, typedef_,
                        union_, unsigned, void_, volatile, while_, asm_,
                        _Alignas, _Alignof, _Atomic, _Bool, _Complex, _Generic, _Imaginary, _Noreturn,
-                       _Static_assert, _Thread_local, __cdecl, __declspec, __attribute__ ];
+                       _Static_assert, _Thread_local, _import, __cdecl, __declspec, __attribute__ ];
 
         foreach (kw; Ckwds)
             tab[kw] = cast(TOK) kw;
@@ -891,6 +893,7 @@ extern (C++) struct Token
         TOK._Thread_local  : "_Thread_local",
 
         // C only extended keywords
+        TOK._import       : "__import",
         TOK.__cdecl        : "__cdecl",
         TOK.__declspec     : "__declspec",
         TOK.__attribute__  : "__attribute__",
diff --git a/gcc/d/dmd/tokens.h b/gcc/d/dmd/tokens.h
index 0a00ae7fc98..a7c9aa55bba 100644
--- a/gcc/d/dmd/tokens.h
+++ b/gcc/d/dmd/tokens.h
@@ -287,6 +287,7 @@ enum class TOK : unsigned char
     _Thread_local_,
 
     // C only extended keywords
+    _import,
     cdecl,
     declspec,
     attribute__,
diff --git a/gcc/d/dmd/traits.d b/gcc/d/dmd/traits.d
index ae8ab9b49fb..ec86bc576bd 100644
--- a/gcc/d/dmd/traits.d
+++ b/gcc/d/dmd/traits.d
@@ -150,6 +150,7 @@ shared static this()
         "hasPostblit",
         "hasCopyConstructor",
         "isCopyable",
+        "parameters"
     ];
 
     StringTable!(bool)* stringTable = cast(StringTable!(bool)*) &traitsStringTable;
@@ -998,7 +999,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
                 e.error("`bool` expected as third argument of `__traits(getOverloads)`, not `%s` of type `%s`", b.toChars(), b.type.toChars());
                 return ErrorExp.get();
             }
-            includeTemplates = b.toBool().hasValue(true);
+            includeTemplates = b.toBool().get();
         }
 
         StringExp se = ex.toStringExp();
@@ -2090,7 +2091,43 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
         auto tup = new TupleExp(e.loc, exps);
         return tup.expressionSemantic(sc);
     }
+    //https://issues.dlang.org/show_bug.cgi?id=22291
+    if (e.ident == Id.parameters)
+    {
+        //No args are valid
+        if (e.args)
+        {
+            char[] contents = cast(char[]) e.args.toString();
+            contents = contents[1..$];
+            contents[$-1] = '\0';
+            e.error("`__traits(parameters)` cannot have arguments, but `%s` was supplied", contents.ptr);
+            return ErrorExp.get();
+        }
 
+        if (sc.func is null)
+        {
+            e.error("`__traits(parameters)` may only be used inside a function");
+            return ErrorExp.get();
+        }
+        assert(sc.func && sc.parent.isFuncDeclaration());
+        auto tf = sc.parent.isFuncDeclaration.type.isTypeFunction();
+        assert(tf);
+        auto exps = new Expressions(0);
+        int addParameterDG(size_t idx, Parameter x)
+        {
+            assert(x.ident);
+            exps.push(new IdentifierExp(e.loc, x.ident));
+            return 0;
+        }
+        /*
+            This is required since not all "parameters" actually have a name
+            until they (tuples) are expanded e.g. an anonymous tuple parameter's
+            contents get given names but not the tuple itself.
+        */
+        Parameter._foreach(tf.parameterList.parameters, &addParameterDG);
+        auto tup = new TupleExp(e.loc, exps);
+        return tup.expressionSemantic(sc);
+    }
     static const(char)[] trait_search_fp(const(char)[] seed, out int cost)
     {
         //printf("trait_search_fp('%s')\n", seed);
diff --git a/gcc/d/dmd/transitivevisitor.d b/gcc/d/dmd/transitivevisitor.d
index 0479d5ad045..8b6ca6545d6 100644
--- a/gcc/d/dmd/transitivevisitor.d
+++ b/gcc/d/dmd/transitivevisitor.d
@@ -1141,6 +1141,12 @@ package mixin template ParseVisitMethods(AST)
         }
     }
 
+    override void visit(AST.ThrowExp e)
+    {
+        //printf("Visiting ThrowExp\n");
+        e.e1.accept(this);
+    }
+
 // Template Parameter
 //===========================================================
 
diff --git a/gcc/d/dmd/typesem.d b/gcc/d/dmd/typesem.d
index 34b363da687..e11f1f7810c 100644
--- a/gcc/d/dmd/typesem.d
+++ b/gcc/d/dmd/typesem.d
@@ -2062,7 +2062,7 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
             switch (mtype.tok)
             {
                 case TOK.enum_:
-                    auto ed = new EnumDeclaration(mtype.loc, mtype.id, Type.tint32);
+                    auto ed = new EnumDeclaration(mtype.loc, mtype.id, mtype.base);
                     declare(ed);
                     mtype.resolved = visitEnum(new TypeEnum(ed));
                     break;
@@ -3940,7 +3940,7 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag)
 
             e = new TupleExp(e.loc, e0, exps);
             Scope* sc2 = sc.push();
-            sc2.flags |= global.params.useDIP1000 == FeatureState.enabled ? SCOPE.onlysafeaccess : SCOPE.noaccesscheck;
+            sc2.flags |= SCOPE.noaccesscheck;
             e = e.expressionSemantic(sc2);
             sc2.pop();
             return e;
@@ -4201,7 +4201,7 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag)
 
             e = new TupleExp(e.loc, e0, exps);
             Scope* sc2 = sc.push();
-            sc2.flags |= global.params.useDIP1000 == FeatureState.enabled ? SCOPE.onlysafeaccess : SCOPE.noaccesscheck;
+            sc2.flags |= SCOPE.noaccesscheck;
             e = e.expressionSemantic(sc2);
             sc2.pop();
             return e;
diff --git a/gcc/d/dmd/visitor.h b/gcc/d/dmd/visitor.h
index 5bad56b7017..5d6b94ccd02 100644
--- a/gcc/d/dmd/visitor.h
+++ b/gcc/d/dmd/visitor.h
@@ -220,6 +220,7 @@ class BinAssignExp;
 class MixinExp;
 class ImportExp;
 class AssertExp;
+class ThrowExp;
 class DotIdExp;
 class DotTemplateExp;
 class DotVarExp;
@@ -511,6 +512,7 @@ public:
     virtual void visit(CallExp *e) { visit((UnaExp *)e); }
     virtual void visit(DotIdExp *e) { visit((UnaExp *)e); }
     virtual void visit(AssertExp *e) { visit((UnaExp *)e); }
+    virtual void visit(ThrowExp *e) { visit((UnaExp *)e); }
     virtual void visit(ImportExp *e) { visit((UnaExp *)e); }
     virtual void visit(DotTemplateInstanceExp *e) { visit((UnaExp *)e); }
     virtual void visit(ArrayExp *e) { visit((UnaExp *)e); }
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index f8d68763c85..dd7ebc842a8 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -1186,6 +1186,14 @@ public:
     this->result_ = build_assign (modifycode, t1, t2);
   }
 
+  /* Build a throw expression.  */
+
+  void visit (ThrowExp *e)
+  {
+    tree arg = build_expr_dtor (e->e1);
+    this->result_ = build_libcall (LIBCALL_THROW, Type::tvoid, 1, arg);
+  }
+
   /* Build a postfix expression.  */
 
   void visit (PostExp *e)
diff --git a/gcc/d/types.cc b/gcc/d/types.cc
index 4b6d2454e1b..8ae6ea1bb78 100644
--- a/gcc/d/types.cc
+++ b/gcc/d/types.cc
@@ -274,6 +274,72 @@ insert_aggregate_field (tree type, tree field, size_t offset)
   TYPE_FIELDS (type) = chainon (TYPE_FIELDS (type), field);
 }
 
+/* Build a bit-field integer type for the given WIDTH and UNSIGNEDP.  */
+
+static tree
+d_build_bitfield_integer_type (unsigned HOST_WIDE_INT width, int unsignedp)
+{
+  /* Same as d_type_for_size, but uses exact match for size.  */
+  if (width == TYPE_PRECISION (d_byte_type))
+    return unsignedp ? d_ubyte_type : d_byte_type;
+
+  if (width == TYPE_PRECISION (d_short_type))
+    return unsignedp ? d_ushort_type : d_short_type;
+
+  if (width == TYPE_PRECISION (d_int_type))
+    return unsignedp ? d_uint_type : d_int_type;
+
+  if (width == TYPE_PRECISION (d_long_type))
+    return unsignedp ? d_ulong_type : d_long_type;
+
+  if (width == TYPE_PRECISION (d_cent_type))
+    return unsignedp ? d_ucent_type : d_cent_type;
+
+  for (int i = 0; i < NUM_INT_N_ENTS; i ++)
+    {
+      if (int_n_enabled_p[i] && width == int_n_data[i].bitsize)
+	{
+	  if (unsignedp)
+	    return int_n_trees[i].unsigned_type;
+	  else
+	    return int_n_trees[i].signed_type;
+	}
+    }
+
+  return build_nonstandard_integer_type (width, unsignedp);
+}
+
+/* Adds BITFIELD into the aggregate TYPE at OFFSET+BITOFFSET.  */
+
+static void
+insert_aggregate_bitfield (tree type, tree bitfield, size_t width,
+			   size_t offset, size_t bitoffset)
+{
+  DECL_FIELD_CONTEXT (bitfield) = type;
+  SET_DECL_OFFSET_ALIGN (bitfield, TYPE_ALIGN (TREE_TYPE (bitfield)));
+  DECL_SIZE (bitfield) = bitsize_int (width);
+  DECL_FIELD_OFFSET (bitfield) = size_int (offset);
+  DECL_FIELD_BIT_OFFSET (bitfield) = bitsize_int (bitoffset);
+
+  TREE_ADDRESSABLE (bitfield) = TYPE_SHARED (TREE_TYPE (bitfield));
+
+  DECL_BIT_FIELD (bitfield) = 1;
+  DECL_BIT_FIELD_TYPE (bitfield) = TREE_TYPE (bitfield);
+
+  layout_decl (bitfield, 0);
+
+  /* Give bit-field its proper type after layout_decl.  */
+  tree orig_type = DECL_BIT_FIELD_TYPE (bitfield);
+  if (width != TYPE_PRECISION (orig_type))
+    {
+      TREE_TYPE (bitfield)
+    	= d_build_bitfield_integer_type (width, TYPE_UNSIGNED (orig_type));
+      SET_DECL_MODE (bitfield, TYPE_MODE (TREE_TYPE (bitfield)));
+    }
+
+  TYPE_FIELDS (type) = chainon (TYPE_FIELDS (type), bitfield);
+}
+
 /* For all decls in the FIELDS chain, adjust their field offset by OFFSET.
    This is done as the frontend puts fields into the outer struct, and so
    their offset is from the beginning of the aggregate.
@@ -356,7 +422,16 @@ layout_aggregate_members (Dsymbols *members, tree context, bool inherited_p)
 	      tree field = create_field_decl (declaration_type (var), ident,
 					      inherited_p, inherited_p);
 	      apply_user_attributes (var, field);
-	      insert_aggregate_field (context, field, var->offset);
+
+	      if (BitFieldDeclaration *bf = var->isBitFieldDeclaration ())
+		{
+		  /* Bit-fields come from an ImportC context, and require the
+		     field be correctly adjusted.  */
+		  insert_aggregate_bitfield (context, field, bf->fieldWidth,
+					     bf->offset, bf->bitOffset);
+		}
+	      else
+  		insert_aggregate_field (context, field, var->offset);
 
 	      /* Because the front-end shares field decls across classes, don't
 		 create the corresponding back-end symbol unless we are adding
diff --git a/gcc/testsuite/gdc.test/compilable/casttuple.d b/gcc/testsuite/gdc.test/compilable/casttuple.d
new file mode 100644
index 00000000000..c4c2bc8874c
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/casttuple.d
@@ -0,0 +1,31 @@
+alias tuple(T...) = T;
+
+void exactMatch()
+{
+    tuple!int tup_1;
+
+    auto i = cast() tup_1;
+    static assert(is(typeof(i) == int));
+    const i_const = cast(const) tup_1;
+    static assert(is(typeof(i_const) == const int));
+
+    auto totup_1 = cast(tuple!int) tup_1;
+    static assert(is(typeof(totup_1) == tuple!int));
+
+    tuple!(int, int) tup_2;
+    auto totup_2 = cast(tuple!(int, int)) tup_2;
+    static assert(is(typeof(totup_2) == tuple!(int, int)));
+}
+
+void implicitConv()
+{
+    tuple!short tup_1;
+    auto totup_1 = cast(tuple!int) tup_1;
+    static assert(is(typeof(tup_1) == tuple!short));
+    static assert(is(typeof(totup_1) == tuple!int));
+
+    tuple!(short, short) tup_2;
+    auto totup_2 = cast(tuple!(int, int)) tup_2;
+    static assert(is(typeof(tup_2) == tuple!(short, short)));
+    static assert(is(typeof(totup_2) == tuple!(int, int)));
+}
diff --git a/gcc/testsuite/gdc.test/compilable/deprecated_override.d b/gcc/testsuite/gdc.test/compilable/deprecated_override.d
new file mode 100644
index 00000000000..c9da34dbfa7
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/deprecated_override.d
@@ -0,0 +1,97 @@
+// https://issues.dlang.org/show_bug.cgi?id=22668
+
+// Overrides with same deprecated'ness are allowed
+
+class SameParent
+{
+    deprecated void foo() {}
+    void foo(int) {}
+
+    void bar(int) {}
+    deprecated void bar() {}
+}
+
+class SameChild : SameParent
+{
+    deprecated override void foo() {}
+    override void foo(int) {}
+
+    override void bar(int) {}
+    deprecated override void bar() {}
+}
+
+/**
+Only the parent declaration is deprecated
+
+TEST_OUTPUT:
+----
+compilable/deprecated_override.d(44): Deprecation: `deprecated_override.IntroducingChild.foo` is overriding the deprecated method `deprecated_override.IntroducingParent.foo`
+compilable/deprecated_override.d(48): Deprecation: `deprecated_override.IntroducingChild.bar` is overriding the deprecated method `deprecated_override.IntroducingParent.bar`
+----
+**/
+
+class IntroducingParent
+{
+    deprecated void foo() {}
+    void foo(int) {}
+
+    void bar(int) {}
+    deprecated void bar() {}
+}
+
+class IntroducingChild : IntroducingParent
+{
+    override void foo() {}
+    override void foo(int) {}
+
+    override void bar(int) {}
+    override void bar() {}
+}
+
+// Unrelated to this path but should this error as well?
+
+class IntroducingGrandchild : IntroducingChild
+{
+    override void foo() {}
+    override void foo(int) {}
+
+    override void bar(int) {}
+    override void bar() {}
+}
+
+/**
+Only the overriding declaration is deprecated
+
+TEST_OUTPUT:
+----
+compilable/deprecated_override.d(83): Deprecation: `deprecated_override.OverrideChild.foo` cannot be marked as `deprecated` because it is overriding a function in the base class
+compilable/deprecated_override.d(87): Deprecation: `deprecated_override.OverrideChild.bar` cannot be marked as `deprecated` because it is overriding a function in the base class
+----
+**/
+
+class OverrideParent
+{
+    void foo() {}
+    void foo(int) {}
+
+    void bar(int) {}
+    void bar() {}
+}
+
+class OverrideChild : OverrideParent
+{
+    deprecated override void foo() {}
+    override void foo(int) {}
+
+    override void bar(int) {}
+    deprecated override void bar() {}
+}
+
+class OverrideGrandChild : OverrideChild
+{
+    deprecated override void foo() {}
+    override void foo(int) {}
+
+    override void bar(int) {}
+    deprecated override void bar() {}
+}
diff --git a/gcc/testsuite/gdc.test/compilable/extra-files/header1.d b/gcc/testsuite/gdc.test/compilable/extra-files/header1.d
index 209d4a0557e..01cf8897bca 100644
--- a/gcc/testsuite/gdc.test/compilable/extra-files/header1.d
+++ b/gcc/testsuite/gdc.test/compilable/extra-files/header1.d
@@ -600,3 +600,9 @@ struct Test14UDA4(string v){}
 void test14x(@Test14UDA1 int, @Test14UDA2("1") int, @test14uda3("2") int, @Test14UDA4!"3" int) {}
 
 void test15x(@(20) void delegate(int) @safe dg){}
+
+T throwStuff(T)(T t)
+{
+    if (false) test13x(1, throw new Exception(""), 2);
+    return t ? t : throw new Exception("Bad stuff happens!");
+}
diff --git a/gcc/testsuite/gdc.test/compilable/fix17635.d b/gcc/testsuite/gdc.test/compilable/fix17635.d
new file mode 100644
index 00000000000..dd14de148a6
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/fix17635.d
@@ -0,0 +1,16 @@
+// https://issues.dlang.org/show_bug.cgi?id=17635
+
+alias T = immutable int;
+
+T** f(const T** input) pure
+{
+    T** output;
+    return output;
+}
+
+void main()
+{
+    T i;
+    T* p = &i;
+    immutable T** r = f(&p);
+}
diff --git a/gcc/testsuite/gdc.test/compilable/fix22291.d b/gcc/testsuite/gdc.test/compilable/fix22291.d
new file mode 100644
index 00000000000..4090c5e2758
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/fix22291.d
@@ -0,0 +1,134 @@
+//https://issues.dlang.org/show_bug.cgi?id=22291
+
+alias AliasSeq(T...) = T;
+void noParameters()
+{
+    static assert(typeof(__traits(parameters)).length == 0);
+}
+void noArgs()
+{
+    //Arguments are not valid, this should not compile
+    static assert(!__traits(compiles, __traits(parameters, 456)));
+}
+shared static this()
+{
+    static assert(typeof(__traits(parameters)).length == 0);
+}
+int echoPlusOne(int x)
+{
+    __traits(parameters)[0] += 1;
+    return x;
+}
+static assert(echoPlusOne(1) == 2);
+class Tree {
+    int opApply(int delegate(size_t, Tree) dg) {
+        if (dg(0, this)) return 1;
+        return 0;
+    }
+}
+void useOpApply(Tree top, int x)
+{
+    foreach(idx; 0..5)
+    {
+        static assert(is(typeof(__traits(parameters)) == AliasSeq!(Tree, int)));
+    }
+    foreach(idx, elem; top)
+    {
+        static assert(is(typeof(__traits(parameters)) == AliasSeq!(size_t, Tree)));
+    }
+}
+class Test
+{
+    static assert(!__traits(compiles, __traits(parameters)));
+    void handle(int x)
+    {
+        static assert(typeof(__traits(parameters)).length == 1);
+    }
+}
+
+int add(int x, int y)
+{
+	return x + y;
+}
+
+auto forwardToAdd(int x, int y)
+{
+	return add(__traits(parameters));
+}
+static assert(forwardToAdd(2, 3) == 5);
+struct TestConstructor
+{
+    int x;
+    string y;
+    //This parameter will not have a name but it's (tuple) members
+    //will
+    this(typeof(this.tupleof))
+    {
+        this.tupleof = __traits(parameters);
+    }
+}
+bool test(int x, string y)
+{
+    auto s = TestConstructor(2, "pi");
+    return s.x == x && s.y == y;
+}
+static assert(test(2, "pi"));
+int testNested(int x)
+{
+    static assert(typeof(__traits(parameters)).length == 1);
+    int add(int x, int y)
+    {
+        static assert(typeof(__traits(parameters)).length == 2);
+        return x + y;
+    }
+    return add(x + 2, x + 3);
+}
+void testPack(Pack...)(Pack x)
+{
+    static assert(is(typeof(__traits(parameters)) == typeof(AliasSeq!(x))));
+}
+
+ref int forwardTest(return ref int x)
+{
+    static assert(__traits(isRef, x) == __traits(isRef, __traits(parameters)[0]));
+    return x;
+}
+
+int testRefness(int x, ref int monkey)
+{
+    {
+        //monkey = x;
+        __traits(parameters)[1] = __traits(parameters)[0];
+    }
+    return x;
+}
+int refTest()
+{
+    int x;
+    testRefness(45, x);
+    return x;
+}
+auto packLength(Pack...)(Pack x)
+{
+    return typeof(__traits(parameters)).length;
+}
+static assert(packLength(2, 3) == 2);
+alias lambda = (x) => typeof(__traits(parameters)).stringof;
+static assert(lambda(1) == "(int)");
+static assert(refTest() == 45);
+
+T testTemplate(T)(scope T input)
+{
+    void chimpInASuit(float set)
+    {
+        static assert(is(typeof(__traits(parameters)) == AliasSeq!(float)));
+    }
+    {
+        __traits(parameters) = AliasSeq!(T.max);
+    }
+    __traits(parameters) = AliasSeq!(T.init);
+    return input;
+}
+
+static assert(testTemplate!long(420) == 0);
+
diff --git a/gcc/testsuite/gdc.test/compilable/imports/cstuff3.c b/gcc/testsuite/gdc.test/compilable/imports/cstuff3.c
new file mode 100644
index 00000000000..f6aaf3b2a4a
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/imports/cstuff3.c
@@ -0,0 +1,6 @@
+// check bugs in importing C files
+
+int squared(int a)
+{
+    return a * a;
+}
diff --git a/gcc/testsuite/gdc.test/compilable/imports/imp22625.c b/gcc/testsuite/gdc.test/compilable/imports/imp22625.c
new file mode 100644
index 00000000000..0d18459b3ab
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/imports/imp22625.c
@@ -0,0 +1 @@
+typedef struct S { int x; } T;
diff --git a/gcc/testsuite/gdc.test/compilable/imports/imp22665.c b/gcc/testsuite/gdc.test/compilable/imports/imp22665.c
new file mode 100644
index 00000000000..f575cff249e
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/imports/imp22665.c
@@ -0,0 +1 @@
+enum E { A };
diff --git a/gcc/testsuite/gdc.test/compilable/imports/test22685b.d b/gcc/testsuite/gdc.test/compilable/imports/test22685b.d
new file mode 100644
index 00000000000..e1854d14726
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/imports/test22685b.d
@@ -0,0 +1,5 @@
+module imports.test22685b;
+
+import imports.test22685c : overloaded;
+
+void overloaded()() { }
diff --git a/gcc/testsuite/gdc.test/compilable/imports/test22685c.d b/gcc/testsuite/gdc.test/compilable/imports/test22685c.d
new file mode 100644
index 00000000000..e2c8ad15910
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/imports/test22685c.d
@@ -0,0 +1,3 @@
+module imports.test22685c;
+
+void overloaded()() { }
diff --git a/gcc/testsuite/gdc.test/compilable/issue22130.d b/gcc/testsuite/gdc.test/compilable/issue22130.d
new file mode 100644
index 00000000000..34a631d2541
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/issue22130.d
@@ -0,0 +1,12 @@
+// https://issues.dlang.org/show_bug.cgi?id=22130
+
+int* f(const int* input) pure nothrow @safe
+{
+    int* output;
+    return output;
+}
+void main() pure nothrow @safe
+{
+    int* c = new int;
+    immutable int* i = f(c);
+}
diff --git a/gcc/testsuite/gdc.test/compilable/noreturn1.d b/gcc/testsuite/gdc.test/compilable/noreturn1.d
index 22734cf48b3..5bba9baa72a 100644
--- a/gcc/testsuite/gdc.test/compilable/noreturn1.d
+++ b/gcc/testsuite/gdc.test/compilable/noreturn1.d
@@ -20,8 +20,7 @@ static assert(!is(noreturn == void));
 
 static assert(is( typeof(assert(0)) == noreturn ));
 
-// Does not parse yet
-// static assert(is( typeof(throw new Exception()) == noreturn ));
+static assert(is( typeof(throw new Exception("")) == noreturn ));
 
 static assert(is(noreturn == noreturn));
 static assert(!is(noreturn == const noreturn));
diff --git a/gcc/testsuite/gdc.test/compilable/test13008.d b/gcc/testsuite/gdc.test/compilable/test13008.d
index fd1f41db9cd..f19fdb7aa54 100644
--- a/gcc/testsuite/gdc.test/compilable/test13008.d
+++ b/gcc/testsuite/gdc.test/compilable/test13008.d
@@ -1,10 +1,6 @@
 // REQUIRED_ARGS: -o-
 // PERMUTE_ARGS: -d -de -dw
-/*
-TEST_OUTPUT*
----
----
-*/
+
 deprecated class Dep { }
 deprecated Dep depFunc1(); // error
 deprecated void depFunc2(Dep); // error
diff --git a/gcc/testsuite/gdc.test/compilable/test18771.d b/gcc/testsuite/gdc.test/compilable/test18771.d
index a71361f8ada..e6a511c3697 100644
--- a/gcc/testsuite/gdc.test/compilable/test18771.d
+++ b/gcc/testsuite/gdc.test/compilable/test18771.d
@@ -1,4 +1,4 @@
-// REQUIRED_ARGS : -c
+// REQUIRED_ARGS: -c
 // EXTRA_FILES: imports/test18771a.d imports/test18771b.d imports/test18771c.d imports/test18771d.d
 // https://issues.dlang.org/show_bug.cgi?id=18771
 
diff --git a/gcc/testsuite/gdc.test/compilable/test19609.d b/gcc/testsuite/gdc.test/compilable/test19609.d
index 2646bd44894..4367df153b7 100644
--- a/gcc/testsuite/gdc.test/compilable/test19609.d
+++ b/gcc/testsuite/gdc.test/compilable/test19609.d
@@ -1,7 +1,7 @@
 // https://issues.dlang.org/show_bug.cgi?id=19609
 // EXTRA_FILES: imports/test19609a.d imports/test19609b.d imports/test19609c.d
 /*
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 compilable/test19609.d(11): Deprecation: module `imports.test19609a` is deprecated - 
 compilable/test19609.d(12): Deprecation: module `imports.test19609b` is deprecated - hello
diff --git a/gcc/testsuite/gdc.test/compilable/test19873.d b/gcc/testsuite/gdc.test/compilable/test19873.d
index 7252edd7520..e69b4df3508 100644
--- a/gcc/testsuite/gdc.test/compilable/test19873.d
+++ b/gcc/testsuite/gdc.test/compilable/test19873.d
@@ -1,4 +1,4 @@
-// PERMUTE_ARGS -preview=dip1000
+// PERMUTE_ARGS: -preview=dip1000
 // https://issues.dlang.org/show_bug.cgi?id=19873
 int* ed(scope int* x)
 {
diff --git a/gcc/testsuite/gdc.test/compilable/test21299a.d b/gcc/testsuite/gdc.test/compilable/test21299a.d
index 3c6d8ec3c11..12cc579889b 100644
--- a/gcc/testsuite/gdc.test/compilable/test21299a.d
+++ b/gcc/testsuite/gdc.test/compilable/test21299a.d
@@ -1,4 +1,4 @@
 // EXTRA_SOURCES: imports/test21299/mtype.d imports/test21299/func.d imports/test21299/rootstringtable.d
 // REQUIRED_ARGS: -main
-// LINK
+// LINK:
 module test21299a;
diff --git a/gcc/testsuite/gdc.test/compilable/test22619.d b/gcc/testsuite/gdc.test/compilable/test22619.d
new file mode 100644
index 00000000000..fd5e894715a
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test22619.d
@@ -0,0 +1,11 @@
+// https://issues.dlang.org/show_bug.cgi?id=22619
+
+struct W1 {
+	int x;
+	this(ref inout W1 rhs) inout { this.x = rhs.x; }
+}
+
+inout(W1) f(inout W1 x) { return x; }
+void g(W1 x) {
+	auto r = f(x);
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test22625.d b/gcc/testsuite/gdc.test/compilable/test22625.d
new file mode 100644
index 00000000000..adf6676a303
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test22625.d
@@ -0,0 +1,4 @@
+// https://issues.dlang.org/show_bug.cgi?id=22625
+// EXTRA_FILES: imports/imp22625.c
+
+import imports.imp22625 : S, T;
diff --git a/gcc/testsuite/gdc.test/compilable/test22646.d b/gcc/testsuite/gdc.test/compilable/test22646.d
new file mode 100644
index 00000000000..ae44d81f4da
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test22646.d
@@ -0,0 +1,21 @@
+// https://issues.dlang.org/show_bug.cgi?id=22646
+
+/*
+TEST_OUTPUT:
+---
+true
+true
+false
+false
+---
+*/
+
+static template Bug(string name)
+{
+    enum bool ok = name.length < 3 || name[0..3] != "pad";
+}
+
+pragma(msg, Bug!"x".ok);
+pragma(msg, Bug!"foo".ok);
+pragma(msg, Bug!"pad".ok);
+pragma(msg, Bug!"pad123".ok);
diff --git a/gcc/testsuite/gdc.test/compilable/test22665.d b/gcc/testsuite/gdc.test/compilable/test22665.d
new file mode 100644
index 00000000000..9d55dbbab1f
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test22665.d
@@ -0,0 +1,22 @@
+// EXTRA_FILES: imports/imp22665.c
+
+// https://issues.dlang.org/show_bug.cgi?id=22665
+
+import imports.imp22665;
+
+E foo1(E e)
+{
+    return e.A; // with qualification, it is an enum
+}
+
+int foo2()
+{
+    return A; // without qualification, it is an int
+}
+
+E foo3(E e)
+{
+    return E.A; // with qualification, it is an enum
+}
+
+
diff --git a/gcc/testsuite/gdc.test/compilable/test22676.d b/gcc/testsuite/gdc.test/compilable/test22676.d
new file mode 100644
index 00000000000..8adc13243a2
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test22676.d
@@ -0,0 +1,25 @@
+// https://issues.dlang.org/show_bug.cgi?id=22676
+template fullyQualifiedName(T)
+{
+    static if (is(T : real))
+        enum fullyQualifiedName;
+
+    enum fullyQualifiedName = null;
+}
+
+static auto _inst()
+{
+    return fullyQualifiedName!(frop);
+}
+
+alias attr = __traits(getAttributes, _inst);
+
+class frop
+{
+    alias type_id = registry!frop;
+}
+
+template registry(T)
+{
+    enum string FOO = fullyQualifiedName!T;
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test22685.d b/gcc/testsuite/gdc.test/compilable/test22685.d
new file mode 100644
index 00000000000..504cc9d5080
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test22685.d
@@ -0,0 +1,11 @@
+// EXTRA_FILES: imports/test22685b.d imports/test22685c.d
+
+module test22685;
+
+import imports.test22685b;
+
+void twoArgs(alias a, alias b)() { }
+
+void main() {
+    twoArgs!(a => 1, overloaded);
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test55.d b/gcc/testsuite/gdc.test/compilable/test55.d
index 6dfc665191e..4b413e12e9c 100644
--- a/gcc/testsuite/gdc.test/compilable/test55.d
+++ b/gcc/testsuite/gdc.test/compilable/test55.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // COMPILED_IMPORTS: imports/test55a.d
 // PERMUTE_ARGS: -dw
 // REQUIRED_ARGS: -d
@@ -17,4 +17,3 @@ class Queue2 {
   alias int ListHead;
   Arm2 a;
 }
-
diff --git a/gcc/testsuite/gdc.test/compilable/testcstuff3.d b/gcc/testsuite/gdc.test/compilable/testcstuff3.d
new file mode 100644
index 00000000000..89228a9bc4a
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/testcstuff3.d
@@ -0,0 +1,4 @@
+// EXTRA_FILES: imports/cstuff3.c
+import imports.cstuff3;
+
+static assert(squared(4) == 16);
diff --git a/gcc/testsuite/gdc.test/compilable/testos.d b/gcc/testsuite/gdc.test/compilable/testos.d
new file mode 100644
index 00000000000..e0eb3a584fb
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/testos.d
@@ -0,0 +1,7 @@
+/* PERMUTE_ARGS: -os=host -os=linux -os=osx -os=freebsd -os=solaris
+ * DISABLED: win32 win64
+ */
+
+void test()
+{
+}
diff --git a/gcc/testsuite/gdc.test/compilable/b16967.d b/gcc/testsuite/gdc.test/fail_compilation/b16967.d
similarity index 70%
rename from gcc/testsuite/gdc.test/compilable/b16967.d
rename to gcc/testsuite/gdc.test/fail_compilation/b16967.d
index 57bc1c1f258..7a2c3e4685f 100644
--- a/gcc/testsuite/gdc.test/compilable/b16967.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/b16967.d
@@ -1,9 +1,8 @@
 /*
- * REQUIRED_ARGS: -c
  * TEST_OUTPUT:
 ---
-compilable/b16967.d(16): Deprecation: switch case fallthrough - use 'goto default;' if intended
-compilable/b16967.d(26): Deprecation: switch case fallthrough - use 'goto default;' if intended
+fail_compilation/b16967.d(15): Error: switch case fallthrough - use 'goto default;' if intended
+fail_compilation/b16967.d(25): Error: switch case fallthrough - use 'goto default;' if intended
 ---
 */
 int foo(int x)
diff --git a/gcc/testsuite/gdc.test/fail_compilation/bug5096.d b/gcc/testsuite/gdc.test/fail_compilation/bug5096.d
new file mode 100644
index 00000000000..2063e41492f
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/bug5096.d
@@ -0,0 +1,14 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/bug5096.d(13): Error: unmatched closing brace
+---
+*/
+void foo(int x)
+    in {
+        assert(x > 0);
+    } do {
+        x++;
+    }
+}
+void main() {}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/bug9631.d b/gcc/testsuite/gdc.test/fail_compilation/bug9631.d
index 33ea0cd7a50..0edd5e99146 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/bug9631.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/bug9631.d
@@ -91,9 +91,9 @@ TEST_OUTPUT:
 ---
 fail_compilation/bug9631.d(106): Error: function `bug9631.targ.ft!().ft(S _param_0)` is not callable using argument types `(S)`
 fail_compilation/bug9631.d(106):        cannot pass argument `x` of type `bug9631.S` to parameter `bug9631.tem!().S _param_0`
-fail_compilation/bug9631.d(107): Error: template `bug9631.targ.ft` cannot deduce function from argument types `!()(S)`
+fail_compilation/bug9631.d(107): Error: none of the overloads of template `bug9631.targ.ft` are callable using argument types `!()(S)`
 fail_compilation/bug9631.d(105):        Candidate is: `ft()(tem!().S)`
-fail_compilation/bug9631.d(109): Error: template `bug9631.targ.ft2` cannot deduce function from argument types `!()(S, int)`
+fail_compilation/bug9631.d(109): Error: none of the overloads of template `bug9631.targ.ft2` are callable using argument types `!()(S, int)`
 fail_compilation/bug9631.d(108):        Candidate is: `ft2(T)(S, T)`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/casttuple.d b/gcc/testsuite/gdc.test/fail_compilation/casttuple.d
new file mode 100644
index 00000000000..d08de08b553
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/casttuple.d
@@ -0,0 +1,25 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/casttuple.d(104): Error: cannot cast `__tup1_field_0` of type `int` to tuple type `(string)`
+fail_compilation/casttuple.d(107): Error: cannot cast `tuple(__tup2_field_0, __tup2_field_1)` of type `(int, int)` to tuple type `(string, string)`
+fail_compilation/casttuple.d(111): Error: cannot cast `tuple(foo, 123)` of type `(int, int)` to tuple type `(string, string)`
+---
+ */
+
+alias tuple(T...) = T;
+
+#line 100
+
+void nomatch()
+{
+    tuple!int tup1;
+    auto x = cast(tuple!string) tup1;
+
+    tuple!(int, int) tup2;
+    auto y = cast(tuple!(string, string)) tup2;
+
+    int foo;
+    alias tup3 = tuple!(foo, 123);
+    auto z = cast(tuple!(string, string)) tup3;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/constraints_aggr.d b/gcc/testsuite/gdc.test/fail_compilation/constraints_aggr.d
index a60ea8c57ae..9f12ae69835 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/constraints_aggr.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/constraints_aggr.d
@@ -2,12 +2,12 @@
 EXTRA_FILES: imports/constraints.d
 TEST_OUTPUT:
 ---
-fail_compilation/constraints_aggr.d(32): Error: template `imports.constraints.C.f` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_aggr.d(32): Error: none of the overloads of template `imports.constraints.C.f` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(60):        Candidate is: `f(T)(T v)`
   with `T = int`
   must satisfy the following constraint:
 `       !P!T`
-fail_compilation/constraints_aggr.d(33): Error: template `imports.constraints.C.g` cannot deduce function from argument types `!()()`
+fail_compilation/constraints_aggr.d(33): Error: none of the overloads of template `imports.constraints.C.g` are callable using argument types `!()()`
 fail_compilation/imports/constraints.d(63):        Candidate is: `g(this T)()`
   with `T = imports.constraints.C`
   must satisfy the following constraint:
diff --git a/gcc/testsuite/gdc.test/fail_compilation/constraints_func1.d b/gcc/testsuite/gdc.test/fail_compilation/constraints_func1.d
index 91dd4055e77..aac87601eb9 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/constraints_func1.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/constraints_func1.d
@@ -2,72 +2,72 @@
 EXTRA_FILES: imports/constraints.d
 TEST_OUTPUT:
 ---
-fail_compilation/constraints_func1.d(79): Error: template `imports.constraints.test1` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func1.d(79): Error: none of the overloads of template `imports.constraints.test1` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(9):        Candidate is: `test1(T)(T v)`
   with `T = int`
   must satisfy the following constraint:
 `       N!T`
-fail_compilation/constraints_func1.d(80): Error: template `imports.constraints.test2` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func1.d(80): Error: none of the overloads of template `imports.constraints.test2` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(10):        Candidate is: `test2(T)(T v)`
   with `T = int`
   must satisfy the following constraint:
 `       !P!T`
-fail_compilation/constraints_func1.d(81): Error: template `imports.constraints.test3` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func1.d(81): Error: none of the overloads of template `imports.constraints.test3` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(11):        Candidate is: `test3(T)(T v)`
   with `T = int`
   must satisfy the following constraint:
 `       N!T`
-fail_compilation/constraints_func1.d(82): Error: template `imports.constraints.test4` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func1.d(82): Error: none of the overloads of template `imports.constraints.test4` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(12):        Candidate is: `test4(T)(T v)`
   with `T = int`
   must satisfy the following constraint:
 `       N!T`
-fail_compilation/constraints_func1.d(83): Error: template `imports.constraints.test5` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func1.d(83): Error: none of the overloads of template `imports.constraints.test5` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(13):        Candidate is: `test5(T)(T v)`
   with `T = int`
   must satisfy one of the following constraints:
 `       N!T
        N!T`
-fail_compilation/constraints_func1.d(84): Error: template `imports.constraints.test6` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func1.d(84): Error: none of the overloads of template `imports.constraints.test6` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(14):        Candidate is: `test6(T)(T v)`
   with `T = int`
   must satisfy one of the following constraints:
 `       N!T
        N!T
        !P!T`
-fail_compilation/constraints_func1.d(85): Error: template `imports.constraints.test7` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func1.d(85): Error: none of the overloads of template `imports.constraints.test7` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(15):        Candidate is: `test7(T)(T v)`
   with `T = int`
   must satisfy one of the following constraints:
 `       N!T
        N!T`
-fail_compilation/constraints_func1.d(86): Error: template `imports.constraints.test8` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func1.d(86): Error: none of the overloads of template `imports.constraints.test8` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(16):        Candidate is: `test8(T)(T v)`
   with `T = int`
   must satisfy the following constraint:
 `       N!T`
-fail_compilation/constraints_func1.d(87): Error: template `imports.constraints.test9` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func1.d(87): Error: none of the overloads of template `imports.constraints.test9` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(17):        Candidate is: `test9(T)(T v)`
   with `T = int`
   must satisfy the following constraint:
 `       !P!T`
-fail_compilation/constraints_func1.d(88): Error: template `imports.constraints.test10` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func1.d(88): Error: none of the overloads of template `imports.constraints.test10` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(18):        Candidate is: `test10(T)(T v)`
   with `T = int`
   must satisfy the following constraint:
 `       !P!T`
-fail_compilation/constraints_func1.d(89): Error: template `imports.constraints.test11` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func1.d(89): Error: none of the overloads of template `imports.constraints.test11` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(19):        Candidate is: `test11(T)(T v)`
   with `T = int`
   must satisfy one of the following constraints:
 `       N!T
        !P!T`
-fail_compilation/constraints_func1.d(90): Error: template `imports.constraints.test12` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func1.d(90): Error: none of the overloads of template `imports.constraints.test12` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(20):        Candidate is: `test12(T)(T v)`
   with `T = int`
   must satisfy the following constraint:
 `       !P!T`
-fail_compilation/constraints_func1.d(92): Error: template `imports.constraints.test1` cannot deduce function from argument types `!()(int, int)`
+fail_compilation/constraints_func1.d(92): Error: none of the overloads of template `imports.constraints.test1` are callable using argument types `!()(int, int)`
 fail_compilation/imports/constraints.d(9):        Candidate is: `test1(T)(T v)`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/constraints_func2.d b/gcc/testsuite/gdc.test/fail_compilation/constraints_func2.d
index 67aa78c1991..a20426d35dc 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/constraints_func2.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/constraints_func2.d
@@ -2,83 +2,83 @@
 EXTRA_FILES: imports/constraints.d
 TEST_OUTPUT:
 ---
-fail_compilation/constraints_func2.d(94): Error: template `imports.constraints.test13` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func2.d(94): Error: none of the overloads of template `imports.constraints.test13` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(23):        Candidate is: `test13(T)(T v)`
   with `T = int`
   must satisfy one of the following constraints:
 `       N!T
        !P!T`
-fail_compilation/constraints_func2.d(95): Error: template `imports.constraints.test14` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func2.d(95): Error: none of the overloads of template `imports.constraints.test14` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(24):        Candidate is: `test14(T)(T v)`
   with `T = int`
   must satisfy one of the following constraints:
 `       !P!T
        N!T`
-fail_compilation/constraints_func2.d(96): Error: template `imports.constraints.test15` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func2.d(96): Error: none of the overloads of template `imports.constraints.test15` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(25):        Candidate is: `test15(T)(T v)`
   with `T = int`
   must satisfy one of the following constraints:
 `       !P!T
        !P!T`
-fail_compilation/constraints_func2.d(97): Error: template `imports.constraints.test16` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func2.d(97): Error: none of the overloads of template `imports.constraints.test16` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(26):        Candidate is: `test16(T)(T v)`
   with `T = int`
   must satisfy one of the following constraints:
 `       N!T
        N!T`
-fail_compilation/constraints_func2.d(98): Error: template `imports.constraints.test17` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func2.d(98): Error: none of the overloads of template `imports.constraints.test17` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(27):        Candidate is: `test17(T)(T v)`
   with `T = int`
   must satisfy the following constraint:
 `       N!T`
-fail_compilation/constraints_func2.d(99): Error: template `imports.constraints.test18` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func2.d(99): Error: none of the overloads of template `imports.constraints.test18` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(28):        Candidate is: `test18(T)(T v)`
   with `T = int`
   must satisfy one of the following constraints:
 `       N!T
        N!T`
-fail_compilation/constraints_func2.d(100): Error: template `imports.constraints.test19` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func2.d(100): Error: none of the overloads of template `imports.constraints.test19` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(29):        Candidate is: `test19(T)(T v)`
   with `T = int`
   must satisfy one of the following constraints:
 `       N!T
        !P!T
        N!T`
-fail_compilation/constraints_func2.d(101): Error: template `imports.constraints.test20` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func2.d(101): Error: none of the overloads of template `imports.constraints.test20` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(30):        Candidate is: `test20(T)(T v)`
   with `T = int`
   must satisfy the following constraint:
 `       N!T`
-fail_compilation/constraints_func2.d(102): Error: template `imports.constraints.test21` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func2.d(102): Error: none of the overloads of template `imports.constraints.test21` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(31):        Candidate is: `test21(T)(T v)`
   with `T = int`
   must satisfy one of the following constraints:
 `       N!T
        N!T`
-fail_compilation/constraints_func2.d(103): Error: template `imports.constraints.test22` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func2.d(103): Error: none of the overloads of template `imports.constraints.test22` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(32):        Candidate is: `test22(T)(T v)`
   with `T = int`
   must satisfy one of the following constraints:
 `       !P!T
        !P!T`
-fail_compilation/constraints_func2.d(104): Error: template `imports.constraints.test23` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func2.d(104): Error: none of the overloads of template `imports.constraints.test23` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(33):        Candidate is: `test23(T)(T v)`
   with `T = int`
   must satisfy one of the following constraints:
 `       !P!T
        N!T
        !P!T`
-fail_compilation/constraints_func2.d(105): Error: template `imports.constraints.test24` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func2.d(105): Error: none of the overloads of template `imports.constraints.test24` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(34):        Candidate is: `test24(R)(R r)`
   with `R = int`
   must satisfy the following constraint:
 `       __traits(hasMember, R, "stuff")`
-fail_compilation/constraints_func2.d(106): Error: template `imports.constraints.test25` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func2.d(106): Error: none of the overloads of template `imports.constraints.test25` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(35):        Candidate is: `test25(T)(T v)`
   with `T = int`
   must satisfy the following constraint:
 `       N!T`
-fail_compilation/constraints_func2.d(107): Error: template `imports.constraints.test26` cannot deduce function from argument types `!(float)(int)`
+fail_compilation/constraints_func2.d(107): Error: none of the overloads of template `imports.constraints.test26` are callable using argument types `!(float)(int)`
 fail_compilation/imports/constraints.d(36):        Candidate is: `test26(T, U)(U u)`
   with `T = float,
        U = int`
diff --git a/gcc/testsuite/gdc.test/fail_compilation/constraints_func3.d b/gcc/testsuite/gdc.test/fail_compilation/constraints_func3.d
index f0a5099358f..6f214b9f07e 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/constraints_func3.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/constraints_func3.d
@@ -2,7 +2,7 @@
 EXTRA_FILES: imports/constraints.d
 TEST_OUTPUT:
 ---
-fail_compilation/constraints_func3.d(53): Error: template `imports.constraints.overload` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func3.d(53): Error: none of the overloads of template `imports.constraints.overload` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(39):        Candidates are: `overload(T)(T v)`
   with `T = int`
   must satisfy the following constraint:
@@ -13,7 +13,7 @@ fail_compilation/imports/constraints.d(40):                        `overload(T)(
 `       !P!T`
 fail_compilation/imports/constraints.d(41):                        `overload(T)(T v1, T v2)`
 fail_compilation/imports/constraints.d(42):                        `overload(T, V)(T v1, V v2)`
-fail_compilation/constraints_func3.d(54): Error: template `imports.constraints.overload` cannot deduce function from argument types `!()(int, string)`
+fail_compilation/constraints_func3.d(54): Error: none of the overloads of template `imports.constraints.overload` are callable using argument types `!()(int, string)`
 fail_compilation/imports/constraints.d(39):        Candidates are: `overload(T)(T v)`
 fail_compilation/imports/constraints.d(40):                        `overload(T)(T v)`
 fail_compilation/imports/constraints.d(41):                        `overload(T)(T v1, T v2)`
@@ -23,21 +23,21 @@ fail_compilation/imports/constraints.d(42):                        `overload(T,
   must satisfy one of the following constraints:
 `       N!T
        N!V`
-fail_compilation/constraints_func3.d(56): Error: template `imports.constraints.variadic` cannot deduce function from argument types `!()()`
+fail_compilation/constraints_func3.d(56): Error: none of the overloads of template `imports.constraints.variadic` are callable using argument types `!()()`
 fail_compilation/imports/constraints.d(43):        Candidate is: `variadic(A, T...)(A a, T v)`
-fail_compilation/constraints_func3.d(57): Error: template `imports.constraints.variadic` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func3.d(57): Error: none of the overloads of template `imports.constraints.variadic` are callable using argument types `!()(int)`
 fail_compilation/imports/constraints.d(43):        Candidate is: `variadic(A, T...)(A a, T v)`
   with `A = int,
        T = ()`
   must satisfy the following constraint:
 `       N!int`
-fail_compilation/constraints_func3.d(58): Error: template `imports.constraints.variadic` cannot deduce function from argument types `!()(int, int)`
+fail_compilation/constraints_func3.d(58): Error: none of the overloads of template `imports.constraints.variadic` are callable using argument types `!()(int, int)`
 fail_compilation/imports/constraints.d(43):        Candidate is: `variadic(A, T...)(A a, T v)`
   with `A = int,
        T = (int)`
   must satisfy the following constraint:
 `       N!int`
-fail_compilation/constraints_func3.d(59): Error: template `imports.constraints.variadic` cannot deduce function from argument types `!()(int, int, int)`
+fail_compilation/constraints_func3.d(59): Error: none of the overloads of template `imports.constraints.variadic` are callable using argument types `!()(int, int, int)`
 fail_compilation/imports/constraints.d(43):        Candidate is: `variadic(A, T...)(A a, T v)`
   with `A = int,
        T = (int, int)`
diff --git a/gcc/testsuite/gdc.test/fail_compilation/constraints_func4.d b/gcc/testsuite/gdc.test/fail_compilation/constraints_func4.d
index 751e618a40c..4048baed69c 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/constraints_func4.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/constraints_func4.d
@@ -3,7 +3,7 @@ EXTRA_FILES: imports/constraints.d
 REQUIRED_ARGS: -verrors=context
 TEST_OUTPUT:
 ---
-fail_compilation/constraints_func4.d(90): Error: template `imports.constraints.overload` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func4.d(90): Error: none of the overloads of template `imports.constraints.overload` are callable using argument types `!()(int)`
     overload(0);
             ^
 fail_compilation/imports/constraints.d(39):        Candidates are: `overload(T)(T v)`
@@ -24,7 +24,7 @@ void overload(T)(T v1, T v2) if (N!T);
 fail_compilation/imports/constraints.d(42):                        `overload(T, V)(T v1, V v2)`
 void overload(T, V)(T v1, V v2) if (N!T || N!V);
      ^
-fail_compilation/constraints_func4.d(91): Error: template `imports.constraints.overload` cannot deduce function from argument types `!()(int, string)`
+fail_compilation/constraints_func4.d(91): Error: none of the overloads of template `imports.constraints.overload` are callable using argument types `!()(int, string)`
     overload(0, "");
             ^
 fail_compilation/imports/constraints.d(39):        Candidates are: `overload(T)(T v)`
@@ -44,13 +44,13 @@ fail_compilation/imports/constraints.d(42):                        `overload(T,
        N!V`
 void overload(T, V)(T v1, V v2) if (N!T || N!V);
      ^
-fail_compilation/constraints_func4.d(93): Error: template `imports.constraints.variadic` cannot deduce function from argument types `!()()`
+fail_compilation/constraints_func4.d(93): Error: none of the overloads of template `imports.constraints.variadic` are callable using argument types `!()()`
     variadic();
             ^
 fail_compilation/imports/constraints.d(43):        Candidate is: `variadic(A, T...)(A a, T v)`
 void variadic(A, T...)(A a, T v) if (N!int);
      ^
-fail_compilation/constraints_func4.d(94): Error: template `imports.constraints.variadic` cannot deduce function from argument types `!()(int)`
+fail_compilation/constraints_func4.d(94): Error: none of the overloads of template `imports.constraints.variadic` are callable using argument types `!()(int)`
     variadic(0);
             ^
 fail_compilation/imports/constraints.d(43):        Candidate is: `variadic(A, T...)(A a, T v)`
@@ -60,7 +60,7 @@ fail_compilation/imports/constraints.d(43):        Candidate is: `variadic(A, T.
 `       N!int`
 void variadic(A, T...)(A a, T v) if (N!int);
      ^
-fail_compilation/constraints_func4.d(95): Error: template `imports.constraints.variadic` cannot deduce function from argument types `!()(int, int)`
+fail_compilation/constraints_func4.d(95): Error: none of the overloads of template `imports.constraints.variadic` are callable using argument types `!()(int, int)`
     variadic(0, 1);
             ^
 fail_compilation/imports/constraints.d(43):        Candidate is: `variadic(A, T...)(A a, T v)`
@@ -70,7 +70,7 @@ fail_compilation/imports/constraints.d(43):        Candidate is: `variadic(A, T.
 `       N!int`
 void variadic(A, T...)(A a, T v) if (N!int);
      ^
-fail_compilation/constraints_func4.d(96): Error: template `imports.constraints.variadic` cannot deduce function from argument types `!()(int, int, int)`
+fail_compilation/constraints_func4.d(96): Error: none of the overloads of template `imports.constraints.variadic` are callable using argument types `!()(int, int, int)`
     variadic(0, 1, 2);
             ^
 fail_compilation/imports/constraints.d(43):        Candidate is: `variadic(A, T...)(A a, T v)`
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag11819b.d b/gcc/testsuite/gdc.test/fail_compilation/diag11819b.d
index a5d6a14212e..aa437271010 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag11819b.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag11819b.d
@@ -1,25 +1,24 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/diag11819b.d(28): Error: unrecognized trait `HasMember`, did you mean `hasMember`?
-fail_compilation/diag11819b.d(29): Error: unrecognized trait `Identifier`, did you mean `identifier`?
-fail_compilation/diag11819b.d(30): Error: unrecognized trait `GetProtection`, did you mean `getProtection`?
-fail_compilation/diag11819b.d(31): Error: unrecognized trait `Parent`, did you mean `parent`?
-fail_compilation/diag11819b.d(32): Error: unrecognized trait `GetMember`, did you mean `getMember`?
-fail_compilation/diag11819b.d(33): Error: unrecognized trait `GetOverloads`, did you mean `getOverloads`?
-fail_compilation/diag11819b.d(34): Error: unrecognized trait `GetVirtualFunctions`, did you mean `getVirtualFunctions`?
-fail_compilation/diag11819b.d(35): Error: unrecognized trait `GetVirtualMethods`, did you mean `getVirtualMethods`?
-fail_compilation/diag11819b.d(36): Error: unrecognized trait `ClassInstanceSize`, did you mean `classInstanceSize`?
-fail_compilation/diag11819b.d(37): Error: unrecognized trait `AllMembers`, did you mean `allMembers`?
-fail_compilation/diag11819b.d(38): Error: unrecognized trait `DerivedMembers`, did you mean `derivedMembers`?
-fail_compilation/diag11819b.d(39): Error: unrecognized trait `IsSame`, did you mean `isSame`?
-fail_compilation/diag11819b.d(40): Error: unrecognized trait `Compiles`, did you mean `compiles`?
-fail_compilation/diag11819b.d(41): Error: unrecognized trait `Parameters`
-fail_compilation/diag11819b.d(42): Error: unrecognized trait `GetAliasThis`, did you mean `getAliasThis`?
-fail_compilation/diag11819b.d(43): Error: unrecognized trait `GetAttributes`, did you mean `getAttributes`?
-fail_compilation/diag11819b.d(44): Error: unrecognized trait `GetFunctionAttributes`, did you mean `getFunctionAttributes`?
-fail_compilation/diag11819b.d(45): Error: unrecognized trait `GetUnitTests`, did you mean `getUnitTests`?
-fail_compilation/diag11819b.d(46): Error: unrecognized trait `GetVirtualIndex`, did you mean `getVirtualIndex`?
+fail_compilation/diag11819b.d(27): Error: unrecognized trait `HasMember`, did you mean `hasMember`?
+fail_compilation/diag11819b.d(28): Error: unrecognized trait `Identifier`, did you mean `identifier`?
+fail_compilation/diag11819b.d(29): Error: unrecognized trait `GetProtection`, did you mean `getProtection`?
+fail_compilation/diag11819b.d(30): Error: unrecognized trait `Parent`, did you mean `parent`?
+fail_compilation/diag11819b.d(31): Error: unrecognized trait `GetMember`, did you mean `getMember`?
+fail_compilation/diag11819b.d(32): Error: unrecognized trait `GetOverloads`, did you mean `getOverloads`?
+fail_compilation/diag11819b.d(33): Error: unrecognized trait `GetVirtualFunctions`, did you mean `getVirtualFunctions`?
+fail_compilation/diag11819b.d(34): Error: unrecognized trait `GetVirtualMethods`, did you mean `getVirtualMethods`?
+fail_compilation/diag11819b.d(35): Error: unrecognized trait `ClassInstanceSize`, did you mean `classInstanceSize`?
+fail_compilation/diag11819b.d(36): Error: unrecognized trait `AllMembers`, did you mean `allMembers`?
+fail_compilation/diag11819b.d(37): Error: unrecognized trait `DerivedMembers`, did you mean `derivedMembers`?
+fail_compilation/diag11819b.d(38): Error: unrecognized trait `IsSame`, did you mean `isSame`?
+fail_compilation/diag11819b.d(39): Error: unrecognized trait `Compiles`, did you mean `compiles`?
+fail_compilation/diag11819b.d(40): Error: unrecognized trait `GetAliasThis`, did you mean `getAliasThis`?
+fail_compilation/diag11819b.d(41): Error: unrecognized trait `GetAttributes`, did you mean `getAttributes`?
+fail_compilation/diag11819b.d(42): Error: unrecognized trait `GetFunctionAttributes`, did you mean `getFunctionAttributes`?
+fail_compilation/diag11819b.d(43): Error: unrecognized trait `GetUnitTests`, did you mean `getUnitTests`?
+fail_compilation/diag11819b.d(44): Error: unrecognized trait `GetVirtualIndex`, did you mean `getVirtualIndex`?
 ---
 */
 
@@ -38,7 +37,6 @@ void main()
     if (__traits(DerivedMembers)) { }
     if (__traits(IsSame)) { }
     if (__traits(Compiles)) { }
-    if (__traits(Parameters)) { }
     if (__traits(GetAliasThis)) { }
     if (__traits(GetAttributes)) { }
     if (__traits(GetFunctionAttributes)) { }
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag13333.d b/gcc/testsuite/gdc.test/fail_compilation/diag13333.d
index 34eeaebedd7..88e8a9d0622 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag13333.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag13333.d
@@ -1,5 +1,5 @@
 /*
-TEST_OUTPUT*
+TEST_OUTPUT:
 ---
 fail_compilation/diag13333.d(29): Error: template instance `VariantN!(maxSize!(S), T)` recursive template expansion
 fail_compilation/diag13333.d(29): Error: template instance `diag13333.maxSize!(S)` error instantiating
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag13942.d b/gcc/testsuite/gdc.test/fail_compilation/diag13942.d
index 992d5b8aadc..aeee10749c1 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag13942.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag13942.d
@@ -2,7 +2,7 @@
 TEST_OUTPUT:
 ---
 fail_compilation/diag13942.d(18): Error: template instance `isRawStaticArray!()` does not match template declaration `isRawStaticArray(T, A...)`
-fail_compilation/diag13942.d(26): Error: template `diag13942.to!double.to` cannot deduce function from argument types `!()()`
+fail_compilation/diag13942.d(26): Error: none of the overloads of template `diag13942.to!double.to` are callable using argument types `!()()`
 fail_compilation/diag13942.d(17):        Candidate is: `to(A...)(A args)`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag16271.d b/gcc/testsuite/gdc.test/fail_compilation/diag16271.d
index b85dc8d21bb..e2095937448 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag16271.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag16271.d
@@ -1,5 +1,5 @@
 /*
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/diag16271.d(10): Error: found `x` when expecting function literal following `ref`
 ---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag16977.d b/gcc/testsuite/gdc.test/fail_compilation/diag16977.d
index 8f991a71edd..9d8dcfdca0c 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag16977.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag16977.d
@@ -3,7 +3,7 @@ TEST_OUTPUT:
 ---
 fail_compilation/diag16977.d(25): Error: undefined identifier `undefined`, did you mean function `undefinedId`?
 fail_compilation/diag16977.d(26): Error: cannot implicitly convert expression `"\x01string"` of type `string` to `int`
-fail_compilation/diag16977.d(27): Error: template `diag16977.templ` cannot deduce function from argument types `!()(int)`
+fail_compilation/diag16977.d(27): Error: none of the overloads of template `diag16977.templ` are callable using argument types `!()(int)`
 fail_compilation/diag16977.d(20):        Candidate is: `templ(S)(S s)`
   with `S = int`
   must satisfy the following constraint:
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag19225.d b/gcc/testsuite/gdc.test/fail_compilation/diag19225.d
index bbb825159f2..a43a7e10e07 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag19225.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag19225.d
@@ -4,7 +4,7 @@ TEST_OUTPUT:
 fail_compilation/diag19225.d(14): Error: basic type expected, not `else`
 fail_compilation/diag19225.d(14):        There's no `static else`, use `else` instead.
 fail_compilation/diag19225.d(14): Error: found `else` without a corresponding `if`, `version` or `debug` statement
-fail_compilation/diag19225.d(15): Error: unrecognized declaration
+fail_compilation/diag19225.d(15): Error: unmatched closing brace
 ---
 */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag8101.d b/gcc/testsuite/gdc.test/fail_compilation/diag8101.d
index a0d245b370a..282665ff8d5 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag8101.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag8101.d
@@ -13,12 +13,12 @@ fail_compilation/diag8101.d(38):                        `diag8101.f_2(int, int,
 fail_compilation/diag8101.d(39):                        `diag8101.f_2(int, int, int, int)`
 fail_compilation/diag8101.d(40):                        `diag8101.f_2(int, int, int, int, int)`
 fail_compilation/diag8101.d(59):        ... (1 more, -v to show) ...
-fail_compilation/diag8101.d(61): Error: template `diag8101.t_0` cannot deduce function from argument types `!()()`
+fail_compilation/diag8101.d(61): Error: none of the overloads of template `diag8101.t_0` are callable using argument types `!()()`
 fail_compilation/diag8101.d(43):        Candidate is: `t_0(T1)()`
-fail_compilation/diag8101.d(62): Error: template `diag8101.t_1` cannot deduce function from argument types `!()()`
+fail_compilation/diag8101.d(62): Error: none of the overloads of template `diag8101.t_1` are callable using argument types `!()()`
 fail_compilation/diag8101.d(45):        Candidates are: `t_1(T1)()`
 fail_compilation/diag8101.d(46):                        `t_1(T1, T2)()`
-fail_compilation/diag8101.d(63): Error: template `diag8101.t_2` cannot deduce function from argument types `!()()`
+fail_compilation/diag8101.d(63): Error: none of the overloads of template `diag8101.t_2` are callable using argument types `!()()`
 fail_compilation/diag8101.d(48):        Candidates are: `t_2(T1)()`
 fail_compilation/diag8101.d(49):                        `t_2(T1, T2)()`
 fail_compilation/diag8101.d(50):                        `t_2(T1, T2, T3)()`
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag8648.d b/gcc/testsuite/gdc.test/fail_compilation/diag8648.d
index f202fb33c40..a04ed7c0a42 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag8648.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag8648.d
@@ -2,13 +2,13 @@
 TEST_OUTPUT:
 ---
 fail_compilation/diag8648.d(18): Error: undefined identifier `X`
-fail_compilation/diag8648.d(29): Error: template `diag8648.foo` cannot deduce function from argument types `!()(Foo!(int, 1))`
+fail_compilation/diag8648.d(29): Error: none of the overloads of template `diag8648.foo` are callable using argument types `!()(Foo!(int, 1))`
 fail_compilation/diag8648.d(18):        Candidate is: `foo(T, n)(X!(T, n))`
 fail_compilation/diag8648.d(20): Error: undefined identifier `a`
-fail_compilation/diag8648.d(31): Error: template `diag8648.bar` cannot deduce function from argument types `!()(Foo!(int, 1))`
+fail_compilation/diag8648.d(31): Error: none of the overloads of template `diag8648.bar` are callable using argument types `!()(Foo!(int, 1))`
 fail_compilation/diag8648.d(20):        Candidate is: `bar(T)(Foo!(T, a))`
 fail_compilation/diag8648.d(20): Error: undefined identifier `a`
-fail_compilation/diag8648.d(32): Error: template `diag8648.bar` cannot deduce function from argument types `!()(Foo!(int, f))`
+fail_compilation/diag8648.d(32): Error: none of the overloads of template `diag8648.bar` are callable using argument types `!()(Foo!(int, f))`
 fail_compilation/diag8648.d(20):        Candidate is: `bar(T)(Foo!(T, a))`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag8684.d b/gcc/testsuite/gdc.test/fail_compilation/diag8684.d
index acfee71d22d..9fbbebfd932 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag8684.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag8684.d
@@ -1,8 +1,9 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/diag8684.d(11): Error: found `;` when expecting `)`
-fail_compilation/diag8684.d(12): Error: semicolon expected, not `for`
+fail_compilation/diag8684.d(12): Error: found `;` when expecting `)`
+fail_compilation/diag8684.d(13): Error: semicolon needed to end declaration of `x`, instead of `for`
+fail_compilation/diag8684.d(12):        `x` declared here
 ---
 */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag9004.d b/gcc/testsuite/gdc.test/fail_compilation/diag9004.d
index 62fce32bbac..37d5bd84f32 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag9004.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag9004.d
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/diag9004.d(21): Error: template `diag9004.bar` cannot deduce function from argument types `!()(Foo!int, int)`
+fail_compilation/diag9004.d(21): Error: none of the overloads of template `diag9004.bar` are callable using argument types `!()(Foo!int, int)`
 fail_compilation/diag9004.d(14):        Candidate is: `bar(FooT)(FooT foo, FooT.T x)`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag9420.d b/gcc/testsuite/gdc.test/fail_compilation/diag9420.d
index 6b2577d910e..92cb47f9500 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag9420.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag9420.d
@@ -1,5 +1,5 @@
 /*
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/diag9420.d(21): Error: function `diag9420.S.t3!().tx()` is not callable using argument types `(int)`
 fail_compilation/diag9420.d(21):        expected 0 argument(s), not 1
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diagin.d b/gcc/testsuite/gdc.test/fail_compilation/diagin.d
index a4dabee073a..eb88a23151a 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diagin.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diagin.d
@@ -4,7 +4,7 @@ TEST_OUTPUT:
 ---
 fail_compilation/diagin.d(14): Error: function `diagin.foo(in int)` is not callable using argument types `()`
 fail_compilation/diagin.d(14):        missing argument for parameter #1: `in int`
-fail_compilation/diagin.d(16): Error: template `diagin.foo1` cannot deduce function from argument types `!()(bool[])`
+fail_compilation/diagin.d(16): Error: none of the overloads of template `diagin.foo1` are callable using argument types `!()(bool[])`
 fail_compilation/diagin.d(20):        Candidate is: `foo1(T)(in T v, string)`
 ---
  */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/dip25.d b/gcc/testsuite/gdc.test/fail_compilation/dip25.d
index 44fec37a002..4e803bebfd4 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/dip25.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/dip25.d
@@ -3,7 +3,7 @@ REQUIRED_ARGS: -de
 TEST_OUTPUT:
 ---
 fail_compilation/dip25.d(17): Deprecation: returning `this.buffer[]` escapes a reference to parameter `this`
-fail_compilation/dip25.d(17):        perhaps annotate the parameter with `return`
+fail_compilation/dip25.d(17):        perhaps annotate the function with `return`
 fail_compilation/dip25.d(22): Error: returning `identity(x)` escapes a reference to local variable `x`
 fail_compilation/dip25.d(23): Deprecation: returning `identity(x)` escapes a reference to parameter `x`
 fail_compilation/dip25.d(23):        perhaps annotate the parameter with `return`
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail10964.d b/gcc/testsuite/gdc.test/fail_compilation/fail10964.d
index 4b31a92f9ab..de3673f7860 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail10964.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail10964.d
@@ -5,8 +5,8 @@ fail_compilation/fail10964.d(28): Error: function `fail10964.S.__postblit` is no
 fail_compilation/fail10964.d(29): Error: function `fail10964.S.__postblit` is not `nothrow`
 fail_compilation/fail10964.d(30): Error: function `fail10964.S.__postblit` is not `nothrow`
 fail_compilation/fail10964.d(33): Error: function `fail10964.S.__postblit` is not `nothrow`
-fail_compilation/fail10964.d(34): Error: function `core.internal.array.construction._d_arraysetctor!(S[], S)._d_arraysetctor` is not `nothrow`
-fail_compilation/fail10964.d(35): Error: function `core.internal.array.construction._d_arrayctor!(S[], S)._d_arrayctor` is not `nothrow`
+fail_compilation/fail10964.d(34): Error: function `fail10964.S.__postblit` is not `nothrow`
+fail_compilation/fail10964.d(35): Error: function `fail10964.S.__postblit` is not `nothrow`
 fail_compilation/fail10964.d(22): Error: `nothrow` function `fail10964.foo` may throw
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail11453a.d b/gcc/testsuite/gdc.test/fail_compilation/fail11453a.d
index 488bc6e0ff9..379e86bf5f3 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail11453a.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail11453a.d
@@ -1,7 +1,7 @@
 // REQUIRED_ARGS: -Ifail_compilation/extra-files
 // EXTRA_SOURCES: extra-files/foo11453.d extra-files/bar11453.d
 /*
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/extra-files/bar11453.d(1): Error: package name 'foo11453' conflicts with usage as a module name in file fail_compilation/extra-files/foo11453.d
 ---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail11453b.d b/gcc/testsuite/gdc.test/fail_compilation/fail11453b.d
index c9d7b965d03..4e99395ac67 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail11453b.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail11453b.d
@@ -1,7 +1,7 @@
 // REQUIRED_ARGS: -Ifail_compilation/extra-files
 // EXTRA_SOURCES: extra-files/bar11453.d extra-files/foo11453.d
 /*
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/extra-files/foo11453.d(1): Error: module `foo11453` from file fail_compilation/extra-files/foo11453.d conflicts with package name foo11453
 ---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail11653.d b/gcc/testsuite/gdc.test/fail_compilation/fail11653.d
index fa69edb573e..4eeb9bea521 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail11653.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail11653.d
@@ -1,9 +1,8 @@
-// REQUIRED_ARGS: -de
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail11653.d(19): Deprecation: switch case fallthrough - use 'goto case;' if intended
-fail_compilation/fail11653.d(24): Deprecation: switch case fallthrough - use 'goto default;' if intended
+fail_compilation/fail11653.d(18): Error: switch case fallthrough - use 'goto case;' if intended
+fail_compilation/fail11653.d(23): Error: switch case fallthrough - use 'goto default;' if intended
 ---
 */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail12744.d b/gcc/testsuite/gdc.test/fail_compilation/fail12744.d
index 46ed9f6db6c..2056c0e2a27 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail12744.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail12744.d
@@ -14,10 +14,10 @@ fail_compilation/fail12744.d(61): Error: template instance `fail12744.bar12744L!
 fail_compilation/fail12744.d(40): Error: incompatible parameter storage classes `lazy` and `out`
 fail_compilation/fail12744.d(62): Error: template instance `fail12744.bar12744L!(foo12744O)` error instantiating
 fail_compilation/fail12744.d(41): Error: incompatible parameter storage classes `auto ref` and `out`
-fail_compilation/fail12744.d(67): Error: template `fail12744.bar12744A` cannot deduce function from argument types `!(foo12744O)(int)`
+fail_compilation/fail12744.d(67): Error: none of the overloads of template `fail12744.bar12744A` are callable using argument types `!(foo12744O)(int)`
 fail_compilation/fail12744.d(41):        Candidate is: `bar12744A(alias f)(auto ref PTT12744!f args)`
 fail_compilation/fail12744.d(41): Error: incompatible parameter storage classes `auto ref` and `lazy`
-fail_compilation/fail12744.d(68): Error: template `fail12744.bar12744A` cannot deduce function from argument types `!(foo12744L)(int)`
+fail_compilation/fail12744.d(68): Error: none of the overloads of template `fail12744.bar12744A` are callable using argument types `!(foo12744L)(int)`
 fail_compilation/fail12744.d(41):        Candidate is: `bar12744A(alias f)(auto ref PTT12744!f args)`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail132.d b/gcc/testsuite/gdc.test/fail_compilation/fail132.d
index 2c271d95ae6..58ce8a1a6bc 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail132.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail132.d
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail132.d(19): Error: outer class `A` `this` needed to `new` nested class `B`
+fail_compilation/fail132.d(19): Error: cannot construct nested class `B` because no implicit `this` reference to outer class `A` is available
 ---
 */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail14669.d b/gcc/testsuite/gdc.test/fail_compilation/fail14669.d
index c5ae8e7a70e..be72663b28e 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail14669.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail14669.d
@@ -4,7 +4,7 @@ TEST_OUTPUT:
 fail_compilation/fail14669.d(11): Error: `auto` can only be used as part of `auto ref` for template function parameters
 fail_compilation/fail14669.d(16): Error: template instance `fail14669.foo1!()` error instantiating
 fail_compilation/fail14669.d(12): Error: `auto` can only be used as part of `auto ref` for template function parameters
-fail_compilation/fail14669.d(17): Error: template `fail14669.foo2` cannot deduce function from argument types `!()(int)`
+fail_compilation/fail14669.d(17): Error: none of the overloads of template `fail14669.foo2` are callable using argument types `!()(int)`
 fail_compilation/fail14669.d(12):        Candidate is: `foo2()(auto int a)`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail162.d b/gcc/testsuite/gdc.test/fail_compilation/fail162.d
index 663e0e1fcbb..a537f108e28 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail162.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail162.d
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail162.d(25): Error: template `fail162.testHelper` cannot deduce function from argument types `!()(string, string)`
+fail_compilation/fail162.d(25): Error: none of the overloads of template `fail162.testHelper` are callable using argument types `!()(string, string)`
 fail_compilation/fail162.d(10):        Candidate is: `testHelper(A...)()`
 fail_compilation/fail162.d(30): Error: template instance `fail162.test!("hello", "world")` error instantiating
 ---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail18417.d b/gcc/testsuite/gdc.test/fail_compilation/fail18417.d
index b32a99b49b6..7da7bd1d597 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail18417.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail18417.d
@@ -1,4 +1,4 @@
-// REQUIRED_ARGS : -de
+// REQUIRED_ARGS: -de
 /*
 TEST_OUTPUT:
 ---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail196.d b/gcc/testsuite/gdc.test/fail_compilation/fail196.d
index 78fc3615c95..c7b28cf8521 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail196.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail196.d
@@ -1,23 +1,24 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail196.d(26): Error: delimited string must end in )"
-fail_compilation/fail196.d(26): Error: Implicit string concatenation is error-prone and disallowed in D
-fail_compilation/fail196.d(26):        Use the explicit syntax instead (concatenating literals is `@nogc`): "foo(xxx)" ~ ";\x0a    assert(s == "
-fail_compilation/fail196.d(27): Error: semicolon expected, not `foo`
-fail_compilation/fail196.d(27): Error: found `");\x0a\x0a    s = q"` when expecting `;` following statement
-fail_compilation/fail196.d(29): Error: found `";\x0a    assert(s == "` when expecting `;` following statement
-fail_compilation/fail196.d(30): Error: found `");\x0a\x0a    s = q"` when expecting `;` following statement
-fail_compilation/fail196.d(32): Error: found `{` when expecting `;` following statement
-fail_compilation/fail196.d(32): Error: found `}` when expecting `;` following statement
-fail_compilation/fail196.d(33): Error: found `foo` when expecting `;` following statement
+fail_compilation/fail196.d(27): Error: delimited string must end in )"
+fail_compilation/fail196.d(27): Error: Implicit string concatenation is error-prone and disallowed in D
+fail_compilation/fail196.d(27):        Use the explicit syntax instead (concatenating literals is `@nogc`): "foo(xxx)" ~ ";\x0a    assert(s == "
+fail_compilation/fail196.d(28): Error: semicolon needed to end declaration of `s`, instead of `foo`
+fail_compilation/fail196.d(27):        `s` declared here
+fail_compilation/fail196.d(28): Error: found `");\x0a\x0a    s = q"` when expecting `;` following statement
+fail_compilation/fail196.d(30): Error: found `";\x0a    assert(s == "` when expecting `;` following statement
+fail_compilation/fail196.d(31): Error: found `");\x0a\x0a    s = q"` when expecting `;` following statement
+fail_compilation/fail196.d(33): Error: found `{` when expecting `;` following statement
 fail_compilation/fail196.d(33): Error: found `}` when expecting `;` following statement
-fail_compilation/fail196.d(35): Error: found `<` when expecting `;` following statement
-fail_compilation/fail196.d(36): Error: found `foo` when expecting `;` following statement
-fail_compilation/fail196.d(36): Error: found `<` instead of statement
-fail_compilation/fail196.d(42): Error: unterminated string constant starting at fail_compilation/fail196.d(42)
-fail_compilation/fail196.d(44): Error: found `End of File` when expecting `}` following compound statement
-fail_compilation/fail196.d(44): Error: found `End of File` when expecting `}` following compound statement
+fail_compilation/fail196.d(34): Error: found `foo` when expecting `;` following statement
+fail_compilation/fail196.d(34): Error: found `}` when expecting `;` following statement
+fail_compilation/fail196.d(36): Error: found `<` when expecting `;` following statement
+fail_compilation/fail196.d(37): Error: found `foo` when expecting `;` following statement
+fail_compilation/fail196.d(37): Error: found `<` instead of statement
+fail_compilation/fail196.d(43): Error: unterminated string constant starting at fail_compilation/fail196.d(43)
+fail_compilation/fail196.d(45): Error: found `End of File` when expecting `}` following compound statement
+fail_compilation/fail196.d(45): Error: found `End of File` when expecting `}` following compound statement
 ---
 */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail19609.d b/gcc/testsuite/gdc.test/fail_compilation/fail19609.d
index c68f1994163..d2e146c79ee 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail19609.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail19609.d
@@ -1,7 +1,7 @@
 // https://issues.dlang.org/show_bug.cgi?id=19609
 /*
 EXTRA_FILES: imports/fail19609a.d imports/fail19609b.d imports/fail19609c.d imports/fail19609d.d
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/imports/fail19609a.d(1): Error: `string` expected for deprecation message, not `([""])` of type `string[]`
 fail_compilation/fail19609.d(16): Deprecation: module `imports.fail19609a` is deprecated
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail19897.d b/gcc/testsuite/gdc.test/fail_compilation/fail19897.d
index d5e6f57d20f..4f5804bc713 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail19897.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail19897.d
@@ -1,5 +1,5 @@
 /*
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/fail19897.d(9): Error: cannot implicitly convert expression `[]` of type `const(char[0])` to `const(char)`
 ---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail207.d b/gcc/testsuite/gdc.test/fail_compilation/fail207.d
index 2a00f7fa907..2fec197c04b 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail207.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail207.d
@@ -1,8 +1,9 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail207.d(10): Error: found end of file instead of initializer
-fail_compilation/fail207.d(10): Error: semicolon expected, not `End of File`
+fail_compilation/fail207.d(11): Error: found end of file instead of initializer
+fail_compilation/fail207.d(11): Error: semicolon needed to end declaration of `x`, instead of `End of File`
+fail_compilation/fail207.d(10):        `x` declared here
 ---
 */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail20730b.d b/gcc/testsuite/gdc.test/fail_compilation/fail20730b.d
index 9320423fe48..00dd9fd7cba 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail20730b.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail20730b.d
@@ -3,7 +3,7 @@ REQUIRED_ARGS: -verrors=spec -o-
 TEST_OUTPUT:
 ---
 (spec:1) fail_compilation/fail20730b.d-mixin-43(43): Error: C style cast illegal, use `cast(int)mod`
-fail_compilation/fail20730b.d(26): Error: template `fail20730b.atomicOp` cannot deduce function from argument types `!("+=")(shared(uint), int)`
+fail_compilation/fail20730b.d(26): Error: none of the overloads of template `fail20730b.atomicOp` are callable using argument types `!("+=")(shared(uint), int)`
 fail_compilation/fail20730b.d(41):        Candidate is: `atomicOp(string op, T, V1)(shared ref T val, V1 mod)`
   with `op = "+=",
        T = uint,
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail21830.d b/gcc/testsuite/gdc.test/fail_compilation/fail21830.d
index 9955c65b696..2e0f84b7777 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail21830.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail21830.d
@@ -1,5 +1,5 @@
 /* REQUIRED_ARGS: -de -unittest
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/fail21830.d(24): Deprecation: struct `fail21830.OldS21830` is deprecated - Deprecated type
 fail_compilation/fail21830.d(24): Deprecation: template `fail21830.test21830(T)(T t) if (is(T == OldS21830))` is deprecated - Deprecated template
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail21831.d b/gcc/testsuite/gdc.test/fail_compilation/fail21831.d
index 699ef0bd39b..39551332e93 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail21831.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail21831.d
@@ -1,5 +1,5 @@
 /* REQUIRED_ARGS: -de -unittest
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/fail21831.d(19): Deprecation: struct `fail21831.S21831` is deprecated - Deprecated type
 fail_compilation/fail21831.d(19): Deprecation: template `fail21831.test21831(T)(T t) if (__traits(isDeprecated, T))` is deprecated - Deprecated template
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail21832.d b/gcc/testsuite/gdc.test/fail_compilation/fail21832.d
index 03753a489a5..98f3df71a15 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail21832.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail21832.d
@@ -1,7 +1,7 @@
 // REQUIRED_ARGS: -de
 // EXTRA_FILES: imports/imp21832.d
 /*
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/fail21832.d(4): Deprecation: function `imports.imp21832.fun` is deprecated
 fail_compilation/fail21832.d(10): Deprecation: template `imports.imp21832.tpl()(char a)` is deprecated
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail220.d b/gcc/testsuite/gdc.test/fail_compilation/fail220.d
index 294dc21b33e..d3905d7fece 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail220.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail220.d
@@ -5,7 +5,7 @@ fail_compilation/fail220.d(12): Error: identifier expected for template value pa
 fail_compilation/fail220.d(12): Error: found `==` when expecting `)`
 fail_compilation/fail220.d(12): Error: found `class` when expecting `)`
 fail_compilation/fail220.d(12): Error: declaration expected, not `)`
-fail_compilation/fail220.d(16): Error: unrecognized declaration
+fail_compilation/fail220.d(16): Error: unmatched closing brace
 ---
 */
 template types (T) {
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail22035.d b/gcc/testsuite/gdc.test/fail_compilation/fail22035.d
index ba03be68124..2e67b4dbea9 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail22035.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail22035.d
@@ -1,5 +1,5 @@
 // https://issues.dlang.org/show_bug.cgi?id=22035
-/* TEST_OUTPUT
+/* TEST_OUTPUT:
 ---
 fail_compilation/fail22035.d(10): Error: found `2` when expecting `:`
 fail_compilation/fail22035.d(10): Error: found `:` instead of statement
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail22084.d b/gcc/testsuite/gdc.test/fail_compilation/fail22084.d
index bd11832adeb..b0ae7224da5 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail22084.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail22084.d
@@ -1,6 +1,6 @@
 // https://issues.dlang.org/show_bug.cgi?id=22084
 /*
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/fail22084.d(22): Error: cannot pass types that need destruction as variadic arguments
 ---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail22133.d b/gcc/testsuite/gdc.test/fail_compilation/fail22133.d
index 338d96dc7e1..a30d430f694 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail22133.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail22133.d
@@ -1,6 +1,6 @@
 // https://issues.dlang.org/show_bug.cgi?id=22133
 /*
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/fail22133.d(16): Error: `s.popFront()()` has no effect
 fail_compilation/fail22133.d(17): Error: template `s.popFront()()` has no type
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail22144.d b/gcc/testsuite/gdc.test/fail_compilation/fail22144.d
index e0fd5b19225..694c1e9955e 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail22144.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail22144.d
@@ -1,5 +1,5 @@
 // https://issues.dlang.org/show_bug.cgi?id=22144
-/* TEST_OUTPUT
+/* TEST_OUTPUT:
 ---
 fail_compilation/fail22144.d(12): Error: cannot cast expression `zarray1` of type `int[0]` to `int[0][]` since sizes don't line up
 ---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail22749.d b/gcc/testsuite/gdc.test/fail_compilation/fail22749.d
new file mode 100644
index 00000000000..56ccac64fae
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail22749.d
@@ -0,0 +1,13 @@
+// EXTRA_FILES: imports/imp22749.c
+/* TEST_OUTPUT:
+---
+fail_compilation/fail22749.d(12): Error: cannot take address of bit-field `field`
+---
+*/
+import imports.imp22749;
+
+void test22749()
+{
+    S22749 s;
+    void* ptr = &s.field;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail236.d b/gcc/testsuite/gdc.test/fail_compilation/fail236.d
index f63eb21a11c..626ec0090f1 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail236.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail236.d
@@ -2,7 +2,7 @@
 TEST_OUTPUT:
 ---
 fail_compilation/fail236.d(14): Error: undefined identifier `x`
-fail_compilation/fail236.d(22): Error: template `fail236.Templ2` cannot deduce function from argument types `!()(int)`
+fail_compilation/fail236.d(22): Error: none of the overloads of template `fail236.Templ2` are callable using argument types `!()(int)`
 fail_compilation/fail236.d(12):        Candidate is: `Templ2(alias a)(x)`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail276.d b/gcc/testsuite/gdc.test/fail_compilation/fail276.d
index 4f9b7c34c0a..b5a99a9b980 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail276.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail276.d
@@ -2,7 +2,7 @@
 TEST_OUTPUT:
 ---
 fail_compilation/fail276.d(19): Error: `this` has no effect
-fail_compilation/fail276.d(15): Error: `this` is only defined in non-static member functions, not `__anonclass2`
+fail_compilation/fail276.d(15): Error: cannot construct anonymous nested class because no implicit `this` reference to outer class is available
 ---
 */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail4269e.d b/gcc/testsuite/gdc.test/fail_compilation/fail4269e.d
index c63bfac4271..8a95b34e891 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail4269e.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail4269e.d
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail4269e.d(10): Error: semicolon expected, not `X5`
+fail_compilation/fail4269e.d(10): Error: semicolon needed to end declaration of `Y` instead of `X5`
 fail_compilation/fail4269e.d(10): Error: no identifier for declarator `X5`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail59.d b/gcc/testsuite/gdc.test/fail_compilation/fail59.d
index 8c51311acce..536049561de 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail59.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail59.d
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail59.d(50): Error: outer class `C1` `this` needed to `new` nested class `C2`
+fail_compilation/fail59.d(50): Error: cannot construct nested class `C2` because no implicit `this` reference to outer class `C1` is available
 ---
 */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail60.d b/gcc/testsuite/gdc.test/fail_compilation/fail60.d
index ec8de0b223c..137dfa9eb52 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail60.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail60.d
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail60.d(14): Error: `this` is only defined in non-static member functions, not `A`
+fail_compilation/fail60.d(14): Error: cannot construct nested class `B` because no implicit `this` reference to outer class `A` is available
 ---
 */
 class A
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail8009.d b/gcc/testsuite/gdc.test/fail_compilation/fail8009.d
index a06dec58664..235e4809d14 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail8009.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail8009.d
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail8009.d(9): Error: template `fail8009.filter` cannot deduce function from argument types `!()(void)`
+fail_compilation/fail8009.d(9): Error: none of the overloads of template `fail8009.filter` are callable using argument types `!()(void)`
 fail_compilation/fail8009.d(8):        Candidate is: `filter(R)(scope bool delegate(ref BAD!R) func)`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail95.d b/gcc/testsuite/gdc.test/fail_compilation/fail95.d
index b1f046ac233..7057a01bf0b 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail95.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail95.d
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail95.d(19): Error: template `fail95.A` cannot deduce function from argument types `!()(int)`
+fail_compilation/fail95.d(19): Error: none of the overloads of template `fail95.A` are callable using argument types `!()(int)`
 fail_compilation/fail95.d(11):        Candidate is: `A(alias T)(T)`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fix17635.d b/gcc/testsuite/gdc.test/fail_compilation/fix17635.d
deleted file mode 100644
index 27f55e06507..00000000000
--- a/gcc/testsuite/gdc.test/fail_compilation/fix17635.d
+++ /dev/null
@@ -1,23 +0,0 @@
-/* REQUIRED_ARGS: -preview=dip1000
-TEST_OUTPUT:
----
-fail_compilation/fix17635.d(22): Error: cannot implicitly convert expression `f(& p)` of type `immutable(int)**` to `immutable(int**)`
----
-*/
-// https://issues.dlang.org/show_bug.cgi?id=17635
-// https://issues.dlang.org/show_bug.cgi?id=15660
-
-alias T = immutable int;
-
-T** f(const T** input) pure
-{
-    T** output;
-    return output;
-}
-
-void main()
-{
-    T i;
-    T* p = &i;
-    immutable T** r = f(&p);
-}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice11856_0.d b/gcc/testsuite/gdc.test/fail_compilation/ice11856_0.d
index 36bc2bd0508..1e51a06ef73 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ice11856_0.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice11856_0.d
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/ice11856_0.d(19): Error: template `ice11856_0.f` cannot deduce function from argument types `!()(int)`
+fail_compilation/ice11856_0.d(19): Error: none of the overloads of template `ice11856_0.f` are callable using argument types `!()(int)`
 fail_compilation/ice11856_0.d(13):        Candidates are: `f(T)(T t)`
 fail_compilation/ice11856_0.d(16):                        `f(T)(T t)`
   with `T = int`
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice11856_1.d b/gcc/testsuite/gdc.test/fail_compilation/ice11856_1.d
index 70991ae4f00..d2a1d1dbcc5 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ice11856_1.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice11856_1.d
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/ice11856_1.d(13): Error: template `ice11856_1.g` cannot deduce function from argument types `!()(A)`
+fail_compilation/ice11856_1.d(13): Error: none of the overloads of template `ice11856_1.g` are callable using argument types `!()(A)`
 fail_compilation/ice11856_1.d(11):        Candidate is: `g(T)(T x)`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice14130.d b/gcc/testsuite/gdc.test/fail_compilation/ice14130.d
index 53e35a61a44..c64fb848484 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ice14130.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice14130.d
@@ -2,7 +2,7 @@
 TEST_OUTPUT:
 ---
 fail_compilation/ice14130.d(10): Error: undefined identifier `Undef`
-fail_compilation/ice14130.d(14): Error: template `ice14130.foo` cannot deduce function from argument types `!()(int)`
+fail_compilation/ice14130.d(14): Error: none of the overloads of template `ice14130.foo` are callable using argument types `!()(int)`
 fail_compilation/ice14130.d(10):        Candidate is: `foo(R, F = Undef)(R r, F s = 0)`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice14907.d b/gcc/testsuite/gdc.test/fail_compilation/ice14907.d
index ac4ba68a858..e1d7aac9f3c 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ice14907.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice14907.d
@@ -6,7 +6,7 @@ fail_compilation/ice14907.d(19):        while looking for match for `S!()`
 fail_compilation/ice14907.d(15): Error: template `ice14907.f(int v = f)()` recursive template expansion
 fail_compilation/ice14907.d(20):        while looking for match for `f!()`
 fail_compilation/ice14907.d(15): Error: template `ice14907.f(int v = f)()` recursive template expansion
-fail_compilation/ice14907.d(21): Error: template `ice14907.f` cannot deduce function from argument types `!()()`
+fail_compilation/ice14907.d(21): Error: none of the overloads of template `ice14907.f` are callable using argument types `!()()`
 fail_compilation/ice14907.d(15):        Candidate is: `f(int v = f)()`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice6538.d b/gcc/testsuite/gdc.test/fail_compilation/ice6538.d
index 0715db5b8a7..f7c639d500a 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ice6538.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice6538.d
@@ -7,7 +7,7 @@
 TEST_OUTPUT:
 ---
 fail_compilation/ice6538.d(23): Error: expression `super` is not a valid template value argument
-fail_compilation/ice6538.d(28): Error: template `ice6538.D.foo` cannot deduce function from argument types `!()()`
+fail_compilation/ice6538.d(28): Error: none of the overloads of template `ice6538.D.foo` are callable using argument types `!()()`
 fail_compilation/ice6538.d(23):        Candidate is: `foo()()`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice9284.d b/gcc/testsuite/gdc.test/fail_compilation/ice9284.d
index a6d84aef241..00602d2de81 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ice9284.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice9284.d
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/ice9284.d(14): Error: template `ice9284.C.__ctor` cannot deduce function from argument types `!()(int)`
+fail_compilation/ice9284.d(14): Error: none of the overloads of template `ice9284.C.__ctor` are callable using argument types `!()(int)`
 fail_compilation/ice9284.d(12):        Candidate is: `__ctor()(string)`
 fail_compilation/ice9284.d(20): Error: template instance `ice9284.C.__ctor!()` error instantiating
 ---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/imp18554.d b/gcc/testsuite/gdc.test/fail_compilation/imports/imp18554.d
deleted file mode 100644
index 9f2a855b9a6..00000000000
--- a/gcc/testsuite/gdc.test/fail_compilation/imports/imp18554.d
+++ /dev/null
@@ -1,4 +0,0 @@
-struct S
-{
-    private int i;
-}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/imp22749.c b/gcc/testsuite/gdc.test/fail_compilation/imports/imp22749.c
new file mode 100644
index 00000000000..7c1850e2bcc
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/imports/imp22749.c
@@ -0,0 +1,4 @@
+struct S22749
+{
+    int field : 1;
+};
diff --git a/gcc/testsuite/gdc.test/fail_compilation/issue21936.d b/gcc/testsuite/gdc.test/fail_compilation/issue21936.d
deleted file mode 100644
index a37aa042e1f..00000000000
--- a/gcc/testsuite/gdc.test/fail_compilation/issue21936.d
+++ /dev/null
@@ -1,32 +0,0 @@
-/* REQUIRED_ARGS: -preview=dip1000 -Ifail_compilation/imports
-TEST_OUTPUT:
----
-fail_compilation/issue21936.d(15): Error: struct `issue21936s.S` variable `field` is not accessible from `@safe` code
-fail_compilation/issue21936.d(15): Error: struct `issue21936s.S` variable `field` is not accessible from `@safe` code
-fail_compilation/issue21936.d(11): Error: template instance `issue21936.constructImplicit!(S)` error instantiating
-fail_compilation/issue21936.d(7):        instantiated from here: `registerConstructors!(S)`
-fail_compilation/issue21936.d(21):        instantiated from here: `registerType!(S)`
----
-*/
-#line 2
-module issue21936;
-import issue21936s;
-struct Handlers {
-    void registerType(T)()
-    {
-        registerConstructors!T;
-    }
-    void registerConstructors(T)()
-    {
-        constructImplicit!T;
-    }
-}
-
-auto constructImplicit(T)(typeof(T.init.tupleof) x = T.init.tupleof)
-{
-}
-
-void registerHandlersDateTime(Handlers handlers)
-{
-	handlers.registerType!(S);
-}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/noreturn.d b/gcc/testsuite/gdc.test/fail_compilation/noreturn.d
index 4a588b4c00d..696081a36b6 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/noreturn.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/noreturn.d
@@ -16,8 +16,8 @@ fail_compilation\noreturn.d(69): Error: `"Accessed expression of type `noreturn`
 fail_compilation\noreturn.d(79):        called from here: `casting(1)`
 fail_compilation\noreturn.d(72): Error: `"Accessed expression of type `noreturn`"`
 fail_compilation\noreturn.d(80):        called from here: `casting(2)`
+fail_compilation/noreturn.d(120): Error: uncaught CTFE exception `object.Exception("")`
 ---
-
 https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1034.md
 */
 
@@ -116,3 +116,5 @@ int inClassRef()
 
 enum forceInClassRef = inClassRef();
 */
+
+enum throwEnum = throw new Exception("");
diff --git a/gcc/testsuite/gdc.test/fail_compilation/noreturn2.d b/gcc/testsuite/gdc.test/fail_compilation/noreturn2.d
index e7d28dc3aaf..2d27d6d8434 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/noreturn2.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/noreturn2.d
@@ -88,3 +88,54 @@ auto returnVoid3(int i)
     else
         return doStuff();
 }
+
+/+
+TEST_OUTPUT:
+---
+fail_compilation/noreturn2.d(104): Error: `object.Exception` is thrown but not caught
+fail_compilation/noreturn2.d(100): Error: `nothrow` function `noreturn2.doesNestedThrow` may throw
+---
++/
+
+int doesNestedThrow(int i) nothrow
+{
+    // Weird formatting is intended to check the loc
+    return i ? i++ :
+            throw
+            new
+            Exception("")
+    ;
+}
+
+int doesNestedThrowThrowable(int i) nothrow
+{
+    return i ? i++ : throw new Error("");
+}
+
+/+
+TEST_OUTPUT:
+---
+fail_compilation/noreturn2.d(130): Error: cannot create instance of interface `I`
+fail_compilation/noreturn2.d(133): Error: can only throw class objects derived from `Throwable`, not type `int[]`
+fail_compilation/noreturn2.d(138): Error: undefined identifier `UnkownException`
+---
++/
+
+int throwInvalid(int i) nothrow
+{
+    static interface I {}
+    // Weird formatting is intended to check the loc
+    return
+            throw
+            new
+            I()
+        ?
+            throw
+            new
+            int[4]
+        :
+            throw
+            new
+            UnkownException("")
+    ;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/objc_class2.d b/gcc/testsuite/gdc.test/fail_compilation/objc_class2.d
index 9d6658c7d24..b4d3cd7889c 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/objc_class2.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/objc_class2.d
@@ -1,4 +1,4 @@
-// EXTRA_OBJC_SOURCES
+// EXTRA_OBJC_SOURCES:
 /*
 TEST_OUTPUT:
 ---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/objc_class3.d b/gcc/testsuite/gdc.test/fail_compilation/objc_class3.d
index f76443d0045..cf2480e9549 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/objc_class3.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/objc_class3.d
@@ -1,4 +1,4 @@
-// EXTRA_OBJC_SOURCES
+// EXTRA_OBJC_SOURCES:
 /*
 TEST_OUTPUT:
 ---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/objc_non_objc_base.d b/gcc/testsuite/gdc.test/fail_compilation/objc_non_objc_base.d
index 6e2b0782bea..9956212d1db 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/objc_non_objc_base.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/objc_non_objc_base.d
@@ -1,4 +1,4 @@
-// EXTRA_OBJC_SOURCES
+// EXTRA_OBJC_SOURCES:
 /*
 TEST_OUTPUT:
 ---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/reg6769.d b/gcc/testsuite/gdc.test/fail_compilation/reg6769.d
index b11fac925a0..86e37e725fd 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/reg6769.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/reg6769.d
@@ -1,5 +1,5 @@
 /*
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/reg6769.d(14): Error: reinterpreting cast from `int[]` to `int[7]*` is not supported in CTFE
 fail_compilation/reg6769.d(27):        called from here: `reg6769a([0, 1, 2, 3, 4, 5, 6])`
diff --git a/gcc/testsuite/gdc.test/fail_compilation/reserved_version.d b/gcc/testsuite/gdc.test/fail_compilation/reserved_version.d
index 43998b9f47c..eeea28c9ee2 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/reserved_version.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/reserved_version.d
@@ -115,6 +115,7 @@ fail_compilation/reserved_version.d(216): Error: version identifier `D_PIE` is r
 fail_compilation/reserved_version.d(217): Error: version identifier `AVR` is reserved and cannot be set
 fail_compilation/reserved_version.d(218): Error: version identifier `D_PreConditions` is reserved and cannot be set
 fail_compilation/reserved_version.d(219): Error: version identifier `D_PostConditions` is reserved and cannot be set
+fail_compilation/reserved_version.d(220): Error: version identifier `D_ProfileGC` is reserved and cannot be set
 ---
 */
 
@@ -236,6 +237,7 @@ version = D_PIE;
 version = AVR;
 version = D_PreConditions;
 version = D_PostConditions;
+version = D_ProfileGC;
 
 // This should work though
 debug = DigitalMars;
@@ -346,3 +348,4 @@ debug = MSP430;
 debug = AVR;
 debug = D_PreConditions;
 debug = D_PostConditions;
+debug = D_ProfileGC;
diff --git a/gcc/testsuite/gdc.test/fail_compilation/reserved_version_switch.d b/gcc/testsuite/gdc.test/fail_compilation/reserved_version_switch.d
index 633330908c8..792ea0a6874 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/reserved_version_switch.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/reserved_version_switch.d
@@ -105,6 +105,7 @@
 // REQUIRED_ARGS: -version=none
 // REQUIRED_ARGS: -version=D_PreConditions
 // REQUIRED_ARGS: -version=D_PostConditions
+// REQUIRED_ARGS: -version=D_ProfileGC
 // REQUIRED_ARGS: -debug=DigitalMars
 // REQUIRED_ARGS: -debug=GNU
 // REQUIRED_ARGS: -debug=LDC
@@ -207,6 +208,7 @@
 // REQUIRED_ARGS: -debug=none
 // REQUIRED_ARGS: -debug=D_PreConditions
 // REQUIRED_ARGS: -debug=D_PostConditions
+// REQUIRED_ARGS: -debug=D_ProfileGC
 /*
 TEST_OUTPUT:
 ---
@@ -315,5 +317,6 @@ Error: version identifier `all` is reserved and cannot be set
 Error: version identifier `none` is reserved and cannot be set
 Error: version identifier `D_PreConditions` is reserved and cannot be set
 Error: version identifier `D_PostConditions` is reserved and cannot be set
+Error: version identifier `D_ProfileGC` is reserved and cannot be set
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/retscope5.d b/gcc/testsuite/gdc.test/fail_compilation/retscope5.d
index 1f9906eb0b1..0625d8e14a0 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/retscope5.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/retscope5.d
@@ -5,7 +5,7 @@ REQUIRED_ARGS: -preview=dip1000
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/retscope5.d(5010): Error: reference `t` assigned to `p` with longer lifetime
+fail_compilation/retscope5.d(5010): Error: address of variable `t` assigned to `p` with longer lifetime
 ---
 */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test15191.d b/gcc/testsuite/gdc.test/fail_compilation/test15191.d
index 1b3078ff051..fea9fb7958c 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test15191.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test15191.d
@@ -1,5 +1,5 @@
 /* TEST_OUTPUT:
-PERMUTE_ARGS -dip1000
+PERMUTE_ARGS: -dip1000
 ---
 fail_compilation/test15191.d(31): Error: returning `&identity(x)` escapes a reference to local variable `x`
 fail_compilation/test15191.d(37): Error: returning `&identityPtr(x)` escapes a reference to local variable `x`
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test16188.d b/gcc/testsuite/gdc.test/fail_compilation/test16188.d
index 38219e987e2..87c55ea4b2f 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test16188.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test16188.d
@@ -2,7 +2,7 @@ TEST_OUTPUT:
 ---
 fail_compilation/test16188.d(1): Error: no identifier for declarator `TEST_OUTPUT`
 fail_compilation/test16188.d(1): Error: declaration expected, not `:`
-fail_compilation/test16188.d(18): Error: unrecognized declaration
+fail_compilation/test16188.d(18): Error: unmatched closing brace
 ---
  */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test16589.d b/gcc/testsuite/gdc.test/fail_compilation/test16589.d
index 7b1f14f526f..0e860815eb7 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test16589.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test16589.d
@@ -3,9 +3,9 @@ REQUIRED_ARGS: -preview=dip1000
 TEST_OUTPUT:
 ---
 fail_compilation/test16589.d(26): Error: returning `&this.data` escapes a reference to parameter `this`
-fail_compilation/test16589.d(26):        perhaps annotate the parameter with `return`
+fail_compilation/test16589.d(26):        perhaps annotate the function with `return`
 fail_compilation/test16589.d(31): Error: returning `&this` escapes a reference to parameter `this`
-fail_compilation/test16589.d(31):        perhaps annotate the parameter with `return`
+fail_compilation/test16589.d(31):        perhaps annotate the function with `return`
 fail_compilation/test16589.d(37): Error: returning `&s.data` escapes a reference to parameter `s`
 fail_compilation/test16589.d(37):        perhaps annotate the parameter with `return`
 fail_compilation/test16589.d(42): Error: returning `&s` escapes a reference to parameter `s`
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test17284.d b/gcc/testsuite/gdc.test/fail_compilation/test17284.d
index a0ea05b0a3a..ef19a561920 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test17284.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test17284.d
@@ -2,7 +2,7 @@ TEST_OUTPUT:
 ---
 fail_compilation/test17284.d(1): Error: no identifier for declarator `TEST_OUTPUT`
 fail_compilation/test17284.d(1): Error: declaration expected, not `:`
-fail_compilation/test17284.d(12): Error: unrecognized declaration
+fail_compilation/test17284.d(12): Error: unmatched closing brace
 ---
 */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test17450.d b/gcc/testsuite/gdc.test/fail_compilation/test17450.d
index 6d0e25a3950..f350cbdd331 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test17450.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test17450.d
@@ -5,7 +5,7 @@ TEST_OUTPUT:
 fail_compilation/test17450.d(17): Error: returning `&s.bar` escapes a reference to parameter `s`
 fail_compilation/test17450.d(17):        perhaps annotate the parameter with `return`
 fail_compilation/test17450.d(20): Error: returning `&this.bar` escapes a reference to parameter `this`
-fail_compilation/test17450.d(20):        perhaps annotate the parameter with `return`
+fail_compilation/test17450.d(20):        perhaps annotate the function with `return`
 ---
 */
 // https://issues.dlang.org/show_bug.cgi?id=17450
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test18554.d b/gcc/testsuite/gdc.test/fail_compilation/test18554.d
deleted file mode 100644
index acbda50c8c3..00000000000
--- a/gcc/testsuite/gdc.test/fail_compilation/test18554.d
+++ /dev/null
@@ -1,24 +0,0 @@
-/* REQUIRED_ARGS: -preview=dip1000
-EXTRA_FILES: imports/imp18554.d
-TEST_OUTPUT:
----
-fail_compilation/test18554.d(16): Error: struct `imp18554.S` variable `i` is not accessible from `@safe` code
----
-*/
-
-// https://issues.dlang.org/show_bug.cgi?id=18554
-
-import imports.imp18554;
-
-void test1() @safe
-{
-    S s;
-    s.tupleof[0] = 1;
-}
-
-void test2()
-{
-    S s;
-    s.tupleof[0] = 1;
-}
-
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test19107.d b/gcc/testsuite/gdc.test/fail_compilation/test19107.d
index 98858b437cd..93d86bf381b 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test19107.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test19107.d
@@ -2,7 +2,7 @@
 EXTRA_FILES: imports/imp19661.d imports/test19107a.d imports/test19107b.d
 TEST_OUTPUT:
 ---
-fail_compilation/test19107.d(24): Error: template `test19107.all` cannot deduce function from argument types `!((c) => c)(string[])`
+fail_compilation/test19107.d(24): Error: none of the overloads of template `test19107.all` are callable using argument types `!((c) => c)(string[])`
 fail_compilation/test19107.d(18):        Candidate is: `all(alias pred, T)(T t)`
   with `pred = __lambda2,
        T = string[]`
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test19193.d b/gcc/testsuite/gdc.test/fail_compilation/test19193.d
index 90227761e7f..e75d90e5a92 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test19193.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test19193.d
@@ -1,6 +1,6 @@
 /*
 REQUIRED_ARGS: -de
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/test19193.d(13): Deprecation: enum member `test19193.T19193!int.A.b` is deprecated
 ---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test21912.d b/gcc/testsuite/gdc.test/fail_compilation/test21912.d
index 8dde98a62b4..5bb92a352a1 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test21912.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test21912.d
@@ -1,6 +1,6 @@
 /*
 PERMUTE_ARGS: -preview=dip1000
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/test21912.d(24): Error: function `test21912.escapeParam` is `@nogc` yet allocates closures with the GC
 fail_compilation/test21912.d(26):        test21912.escapeParam.__lambda2 closes over variable i at fail_compilation/test21912.d(24)
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test22298.d b/gcc/testsuite/gdc.test/fail_compilation/test22298.d
new file mode 100644
index 00000000000..cdb1a3eb508
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test22298.d
@@ -0,0 +1,30 @@
+/*
+REQUIRED_ARGS: -preview=dip1000
+TEST_OUTPUT:
+---
+fail_compilation/test22298.d(18): Error: scope variable `i` assigned to `p` with longer lifetime
+fail_compilation/test22298.d(29): Error: scope variable `y` assigned to `x` with longer lifetime
+---
+*/
+
+void g(scope void delegate(scope int*) @safe cb) @safe {
+	int x = 42;
+	cb(&x);
+}
+
+void main() @safe {
+	int* p;
+	void f(scope int* i) @safe {
+		p = i;
+	}
+
+	g(&f);
+	// address of x has escaped g
+	assert(*p == 42);
+}
+
+void f() @safe {
+    mixin("scope int* x;");
+    scope int* y;
+    x = y;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test22541.d b/gcc/testsuite/gdc.test/fail_compilation/test22541.d
new file mode 100644
index 00000000000..910db0a955b
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test22541.d
@@ -0,0 +1,18 @@
+/* REQUIRED_ARGS: -preview=dip1000
+TEST_OUTPUT:
+---
+fail_compilation/test22541.d(104): Error: returning `i` escapes a reference to parameter `i`
+fail_compilation/test22541.d(104):        perhaps annotate the parameter with `return`
+---
+ */
+
+/* https://issues.dlang.org/show_bug.cgi?id=22541
+ */
+
+#line 100
+
+@safe
+ref int newe(ref return scope int i) // ref, error
+{
+    return i;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test22709.d b/gcc/testsuite/gdc.test/fail_compilation/test22709.d
new file mode 100644
index 00000000000..dd5258e0b37
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test22709.d
@@ -0,0 +1,29 @@
+/*
+REQUIRED_ARGS: -preview=dip1000
+TEST_OUTPUT:
+---
+fail_compilation/test22709.d(15): Error: address of variable `local` assigned to `arr` with longer lifetime
+fail_compilation/test22709.d(20): Error: address of variable `local` assigned to `arr` with longer lifetime
+---
+*/
+
+// https://issues.dlang.org/show_bug.cgi?id=22709
+@safe:
+
+void escape(ref ubyte[] arr, ref ubyte[64] local)
+{
+    arr = local[];
+}
+
+void escape1(ref ubyte[64] local, ref ubyte[] arr)
+{
+    arr = local[];
+}
+
+ubyte[] getArr()
+{
+    ubyte[64] blob;
+    ubyte[] arr;
+    escape(arr, blob[]);
+    return arr;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test3818.d b/gcc/testsuite/gdc.test/fail_compilation/test3818.d
new file mode 100644
index 00000000000..c66db85a930
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test3818.d
@@ -0,0 +1,27 @@
+/* TEST_OUTPUT:
+---
+fail_compilation/test3818.d(104): Error: missing `; expression` before `)` of `foreach`
+fail_compilation/test3818.d(104):        perhaps the `;` goes before `a`
+fail_compilation/test3818.d(109): Error: missing `; expression` before `)` of `foreach`
+fail_compilation/test3818.d(109):        perhaps the `;` goes before `c`
+fail_compilation/test3818.d(110): Error: declaration expected, not `{`
+---
+*/
+
+// https://issues.dlang.org/show_bug.cgi?id=3818
+
+#line 100
+
+void test1()
+{
+    int[10] a;
+    foreach (i, x, a)
+    {
+    }
+}
+
+static foreach (a, b, c)
+{
+}
+
+
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test9701.d b/gcc/testsuite/gdc.test/fail_compilation/test9701.d
index 384c51444b1..a0310c413fb 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test9701.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test9701.d
@@ -1,5 +1,5 @@
 /*
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/test9701.d(38): Error: `@safe` is not a valid attribute for enum members
 fail_compilation/test9701.d(39): Error: `@system` is not a valid attribute for enum members
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test9701b.d b/gcc/testsuite/gdc.test/fail_compilation/test9701b.d
index 16c25413ecb..725a4cd0ea6 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test9701b.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test9701b.d
@@ -1,6 +1,6 @@
 /*
 REQUIRED_ARGS: -de
-TEST_OUTPUT
+TEST_OUTPUT:
 ---
 fail_compilation/test9701b.d(20): Deprecation: enum member `test9701b.Enum.e0` is deprecated
 fail_compilation/test9701b.d(21): Deprecation: enum member `test9701b.Enum.e1` is deprecated - message
diff --git a/gcc/testsuite/gdc.test/fail_compilation/traits_parameters.d b/gcc/testsuite/gdc.test/fail_compilation/traits_parameters.d
new file mode 100644
index 00000000000..5021c540b29
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/traits_parameters.d
@@ -0,0 +1,10 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/traits_parameters.d(9): Error: `__traits(parameters)` cannot have arguments, but `234` was supplied
+fail_compilation/traits_parameters.d(10): Error: `__traits(parameters)` may only be used inside a function
+---
+*/
+
+typeof(__traits(parameters, 234)) xyz;
+typeof(__traits(parameters)) x;
diff --git a/gcc/testsuite/gdc.test/runnable/a18.d b/gcc/testsuite/gdc.test/runnable/a18.d
index f568982acee..c8ed60db675 100644
--- a/gcc/testsuite/gdc.test/runnable/a18.d
+++ b/gcc/testsuite/gdc.test/runnable/a18.d
@@ -1,5 +1,5 @@
 /*
-COMPILE_SEPARATELY
+COMPILE_SEPARATELY:
 EXTRA_SOURCES: imports/a18a.d
 PERMUTE_ARGS:
 RUN_OUTPUT:
diff --git a/gcc/testsuite/gdc.test/runnable/a19.d b/gcc/testsuite/gdc.test/runnable/a19.d
index 574f95cae8f..3681d97d793 100644
--- a/gcc/testsuite/gdc.test/runnable/a19.d
+++ b/gcc/testsuite/gdc.test/runnable/a19.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/a19a.d
 // PERMUTE_ARGS:
 
diff --git a/gcc/testsuite/gdc.test/runnable/b26.d b/gcc/testsuite/gdc.test/runnable/b26.d
index 54e28daaa26..b80d0724ba9 100644
--- a/gcc/testsuite/gdc.test/runnable/b26.d
+++ b/gcc/testsuite/gdc.test/runnable/b26.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/b26a.d
 // PERMUTE_ARGS:
 
diff --git a/gcc/testsuite/gdc.test/runnable/class_opCmp.d b/gcc/testsuite/gdc.test/runnable/class_opCmp.d
new file mode 100644
index 00000000000..43f31ac563e
--- /dev/null
+++ b/gcc/testsuite/gdc.test/runnable/class_opCmp.d
@@ -0,0 +1,25 @@
+class A
+{
+    int x;
+    this(int a) { x = a; }
+
+    alias opCmp = Object.opCmp;
+    alias opCmp = my_cmp;
+
+    final int my_cmp(A a)
+    {
+        return x - a.x;
+    }
+}
+
+void main()
+{
+    auto a1 = new A(1);
+    auto a2 = new A(2);
+    A a_null = null;
+    assert(a1 > a_null);
+    assert(a_null < a1);
+    assert(!(a1 < a1));
+    assert(a1 < a2);
+    assert(a2 > a1);
+}
diff --git a/gcc/testsuite/gdc.test/runnable/fix22624.d b/gcc/testsuite/gdc.test/runnable/fix22624.d
new file mode 100644
index 00000000000..542899f5e9b
--- /dev/null
+++ b/gcc/testsuite/gdc.test/runnable/fix22624.d
@@ -0,0 +1,19 @@
+// https://issues.dlang.org/show_bug.cgi?id=22624
+// EXTRA_FILES: imports/imp22624.c
+
+import core.stdc.stdio;
+import imports.imp22624;
+
+struct S
+{
+    B b;
+    ulong y = 0x1234_0000_5678;
+}
+
+int main()
+{
+    S s;
+    //printf("%llx\n", s.y);
+    assert(s.y == 0x1234_0000_5678);
+    return 0;
+}
diff --git a/gcc/testsuite/gdc.test/runnable/ice15138.d b/gcc/testsuite/gdc.test/runnable/ice15138.d
index 14d6bfb6020..95b8c274c00 100644
--- a/gcc/testsuite/gdc.test/runnable/ice15138.d
+++ b/gcc/testsuite/gdc.test/runnable/ice15138.d
@@ -1,6 +1,6 @@
 // EXTRA_SOURCES: imports/ice15138a.d
 // PERMUTE_ARGS: -unittest -inline
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 
 import imports.ice15138a;
 
diff --git a/gcc/testsuite/gdc.test/runnable/ice15176.d b/gcc/testsuite/gdc.test/runnable/ice15176.d
index 357207d13cb..b47b4ec03cc 100644
--- a/gcc/testsuite/gdc.test/runnable/ice15176.d
+++ b/gcc/testsuite/gdc.test/runnable/ice15176.d
@@ -1,5 +1,5 @@
 // EXTRA_SOURCES: imports/ice15176a.d imports/ice15176b.d
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 
 import imports.ice15176a;
 
diff --git a/gcc/testsuite/gdc.test/runnable/ice15200.d b/gcc/testsuite/gdc.test/runnable/ice15200.d
index b4e2cc3c1c8..2e1abbea4e2 100644
--- a/gcc/testsuite/gdc.test/runnable/ice15200.d
+++ b/gcc/testsuite/gdc.test/runnable/ice15200.d
@@ -1,5 +1,5 @@
 // EXTRA_SOURCES: imports/ice15200a.d imports/ice15200b.d
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 
 module ice15200;
 
diff --git a/gcc/testsuite/gdc.test/runnable/imports/imp22624.c b/gcc/testsuite/gdc.test/runnable/imports/imp22624.c
new file mode 100644
index 00000000000..ea726d3e3f3
--- /dev/null
+++ b/gcc/testsuite/gdc.test/runnable/imports/imp22624.c
@@ -0,0 +1,6 @@
+
+struct B
+{
+    unsigned int x : 1;
+//    unsigned int x;
+};
diff --git a/gcc/testsuite/gdc.test/runnable/issue16995.d b/gcc/testsuite/gdc.test/runnable/issue16995.d
index 3b028d42bf6..0d59882065a 100644
--- a/gcc/testsuite/gdc.test/runnable/issue16995.d
+++ b/gcc/testsuite/gdc.test/runnable/issue16995.d
@@ -1,5 +1,5 @@
 // REQUIRED_ARGS: -unittest
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/module_with_tests.d imports/another_module_with_tests.d
 
 import imports.module_with_tests;
diff --git a/gcc/testsuite/gdc.test/runnable/link10425.d b/gcc/testsuite/gdc.test/runnable/link10425.d
index 95faf6f03da..d0825165765 100644
--- a/gcc/testsuite/gdc.test/runnable/link10425.d
+++ b/gcc/testsuite/gdc.test/runnable/link10425.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/bug10425.d
 
 import imports.bug10425;
diff --git a/gcc/testsuite/gdc.test/runnable/link11069b.d b/gcc/testsuite/gdc.test/runnable/link11069b.d
index 658f46eb51b..33992d177b3 100644
--- a/gcc/testsuite/gdc.test/runnable/link11069b.d
+++ b/gcc/testsuite/gdc.test/runnable/link11069b.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/link11069x.d
 // EXTRA_SOURCES: imports/link11069y.d
 // EXTRA_SOURCES: imports/link11069z.d
diff --git a/gcc/testsuite/gdc.test/runnable/link11395.d b/gcc/testsuite/gdc.test/runnable/link11395.d
index fe25be1ab7f..160225e99e1 100644
--- a/gcc/testsuite/gdc.test/runnable/link11395.d
+++ b/gcc/testsuite/gdc.test/runnable/link11395.d
@@ -1,6 +1,6 @@
 // EXTRA_SOURCES: imports/link11395a.d
 // PERMUTE_ARGS:
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 module link11395;
 import imports.link11395a;
 
diff --git a/gcc/testsuite/gdc.test/runnable/link12010.d b/gcc/testsuite/gdc.test/runnable/link12010.d
index 49c4eb184b1..fc838d80f89 100644
--- a/gcc/testsuite/gdc.test/runnable/link12010.d
+++ b/gcc/testsuite/gdc.test/runnable/link12010.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/a12010.d
 // EXTRA_FILES: imports/std12010container.d
 // REQUIRED_ARGS: -release
diff --git a/gcc/testsuite/gdc.test/runnable/link13394.d b/gcc/testsuite/gdc.test/runnable/link13394.d
index aea86862a65..8af0d36590f 100644
--- a/gcc/testsuite/gdc.test/runnable/link13394.d
+++ b/gcc/testsuite/gdc.test/runnable/link13394.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/link13394a.d
 
 module link13394;
diff --git a/gcc/testsuite/gdc.test/runnable/link13400.d b/gcc/testsuite/gdc.test/runnable/link13400.d
index fbb9ec7574e..3fc4dfb0b2e 100644
--- a/gcc/testsuite/gdc.test/runnable/link13400.d
+++ b/gcc/testsuite/gdc.test/runnable/link13400.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/link13400a.d
 
 import imports.link13400a;
diff --git a/gcc/testsuite/gdc.test/runnable/link13415.d b/gcc/testsuite/gdc.test/runnable/link13415.d
index 782bb6bbd27..000ece33e4e 100644
--- a/gcc/testsuite/gdc.test/runnable/link13415.d
+++ b/gcc/testsuite/gdc.test/runnable/link13415.d
@@ -2,7 +2,7 @@
 EXTRA_SOURCES: imports/link13415a.d
 REQUIRED_ARGS: -inline
 PERMUTE_ARGS: -allinst -unittest -debug
-COMPILE_SEPARATELY
+COMPILE_SEPARATELY:
 RUN_OUTPUT:
 ---
 i = 77;
diff --git a/gcc/testsuite/gdc.test/runnable/link14588.d b/gcc/testsuite/gdc.test/runnable/link14588.d
index 2ca4b52f67d..cfc81574ca3 100644
--- a/gcc/testsuite/gdc.test/runnable/link14588.d
+++ b/gcc/testsuite/gdc.test/runnable/link14588.d
@@ -1,6 +1,6 @@
 // EXTRA_SOURCES: imports/link14588a.d
 // PERMUTE_ARGS: -allinst -unittest -debug -inline
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 
 import imports.link14588a;
 
diff --git a/gcc/testsuite/gdc.test/runnable/link14814.d b/gcc/testsuite/gdc.test/runnable/link14814.d
index ed06500a9b3..10b6b6d3794 100644
--- a/gcc/testsuite/gdc.test/runnable/link14814.d
+++ b/gcc/testsuite/gdc.test/runnable/link14814.d
@@ -1,6 +1,6 @@
 // EXTRA_SOURCES: imports/link14814a.d
 // PERMUTE_ARGS: -inline -release -g -O -fPIC
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 
 import imports.link14814a;
 
diff --git a/gcc/testsuite/gdc.test/runnable/link15017.d b/gcc/testsuite/gdc.test/runnable/link15017.d
index 16187a8b404..5d395479a48 100644
--- a/gcc/testsuite/gdc.test/runnable/link15017.d
+++ b/gcc/testsuite/gdc.test/runnable/link15017.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/std15017variant.d
 /*
 TEST_OUTPUT:
diff --git a/gcc/testsuite/gdc.test/runnable/link7745.d b/gcc/testsuite/gdc.test/runnable/link7745.d
index 9a0eccffef3..a0fdad53448 100644
--- a/gcc/testsuite/gdc.test/runnable/link7745.d
+++ b/gcc/testsuite/gdc.test/runnable/link7745.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/link7745b.d
 // PERMUTE_ARGS:
 
diff --git a/gcc/testsuite/gdc.test/runnable/link8023.d b/gcc/testsuite/gdc.test/runnable/link8023.d
index d4c32cbaa8e..e92b1504fe9 100644
--- a/gcc/testsuite/gdc.test/runnable/link8023.d
+++ b/gcc/testsuite/gdc.test/runnable/link8023.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/link8023b.d
 // PERMUTE_ARGS: -inline -release
 
diff --git a/gcc/testsuite/gdc.test/runnable/link9571.d b/gcc/testsuite/gdc.test/runnable/link9571.d
index 1efdbdd46e3..caa9c78405e 100644
--- a/gcc/testsuite/gdc.test/runnable/link9571.d
+++ b/gcc/testsuite/gdc.test/runnable/link9571.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/link9571a.d
 
 import imports.link9571a;
diff --git a/gcc/testsuite/gdc.test/runnable/linktypeinfo.d b/gcc/testsuite/gdc.test/runnable/linktypeinfo.d
index 04579a26c7a..508e094310b 100644
--- a/gcc/testsuite/gdc.test/runnable/linktypeinfo.d
+++ b/gcc/testsuite/gdc.test/runnable/linktypeinfo.d
@@ -1,6 +1,6 @@
 // EXTRA_SOURCES: imports/linktypeinfo_file.d
 // PERMUTE_ARGS: -g -inline -unittest -debug
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 
 import imports.linktypeinfo_file;
 
diff --git a/gcc/testsuite/gdc.test/runnable/noreturn1.d b/gcc/testsuite/gdc.test/runnable/noreturn1.d
index 1da0479d9f6..7d15b54a213 100644
--- a/gcc/testsuite/gdc.test/runnable/noreturn1.d
+++ b/gcc/testsuite/gdc.test/runnable/noreturn1.d
@@ -112,10 +112,162 @@ void test3()
     }
 }
 
+/*****************************************/
+
+Exception collectException(void function() f)
+{
+    try
+    {
+        f();
+        return null;
+    }
+    catch (Exception e)
+        return e;
+}
+
+
+int return_()
+{
+    return throw new Exception("Return");
+}
+
+void ternary(int i)
+{
+    i > 0 ? i++ : throw new Exception("Ternary");
+}
+
+void call()
+{
+    ternary(throw new Exception("Call"));
+}
+
+void arrayLiteral()
+{
+    int[] arr = [
+        1,
+        throw new Exception("ArrayLiteral"),
+        2
+    ];
+}
+
+void assocArrayLiteral()
+{
+    int[string] arr = [
+        "A": 1,
+        "B": throw new Exception("AssocArrayLiteral"),
+        "C": 2
+    ];
+}
+
+void testThrowExpression()
+{
+    Exception ae = collectException({ return_(); });
+    assert(ae);
+
+    ae = collectException({ ternary(1); });
+    assert(!ae);
+
+    ae = collectException({ ternary(-1); });
+    assert(ae);
+
+    ae = collectException(&call);
+    assert(ae);
+    assert(ae.msg == "Call");
+
+    ae = collectException(&arrayLiteral);
+    assert(ae);
+
+    ae = collectException(&assocArrayLiteral);
+    assert(ae);
+}
+
+
+/*****************************************/
+
+/// Verify that throws does not screw with side effects
+void testThrowSideEffect()
+{
+    static void foo(bool, void*, int) {}
+
+    bool b;
+    int i;
+
+    try
+    {
+        foo(b = true, throw new Exception(""), i++);
+        assert(false);
+    }
+    catch (Exception) {}
+
+    assert(b == true);
+    assert(i == 0);
+}
+
+/// Verify that throws does not screw with dtors
+void testThrowDtor()
+{
+    static struct S
+    {
+        __gshared int destructed;
+        int id;
+
+        ~this()
+        {
+            assert(!(destructed & id));
+            destructed |= id;
+        }
+
+        string getMessage()
+        {
+            // Force runtime dependency
+            return destructed ? "Already destructed" : "Valid";
+        }
+    }
+
+    static void fooD(S, int, S) {}
+    bool caught;
+
+    try
+    {
+        fooD(S(1), throw new Exception(S(2).getMessage()), S(4));
+        assert(false);
+    }
+    catch (Exception e)
+    {
+        caught = true;
+        assert(e.msg == "Valid");
+    }
+    assert(caught);
+    assert(S.destructed == (1 | 2));
+
+
+    static void fooC(S, int, S) {}
+    caught = false;
+    S.destructed = 0;
+
+    try
+    {
+        fooC(S(1), throw new Exception(S(2).getMessage()), S(4));
+        assert(false);
+    }
+    catch (Exception e)
+    {
+        caught = true;
+        assert(e.msg == "Valid");
+    }
+    assert(caught);
+    assert(S.destructed == (1 | 2));
+}
+
+/*****************************************/
+
 int main()
 {
     test1();
     test2();
     test3();
+    testThrowExpression();
+    testThrowSideEffect();
+    testThrowDtor();
     return 0;
 }
diff --git a/gcc/testsuite/gdc.test/runnable/test11039.d b/gcc/testsuite/gdc.test/runnable/test11039.d
index 8c2e624499b..cc5cdba0504 100644
--- a/gcc/testsuite/gdc.test/runnable/test11039.d
+++ b/gcc/testsuite/gdc.test/runnable/test11039.d
@@ -1,5 +1,5 @@
 
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/test11039b.d
 
 import imports.test11039b;
diff --git a/gcc/testsuite/gdc.test/runnable/test11239.d b/gcc/testsuite/gdc.test/runnable/test11239.d
index 9ace1cf95ab..34202357772 100644
--- a/gcc/testsuite/gdc.test/runnable/test11239.d
+++ b/gcc/testsuite/gdc.test/runnable/test11239.d
@@ -1,6 +1,6 @@
 // EXTRA_SOURCES: imports/inc11239.d
 // REQUIRED_ARGS: -debug
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // PERMUTE_ARGS:
 
 import imports.inc11239;
diff --git a/gcc/testsuite/gdc.test/runnable/test11447a.d b/gcc/testsuite/gdc.test/runnable/test11447a.d
index cced4779c89..b4e7b1fb088 100644
--- a/gcc/testsuite/gdc.test/runnable/test11447a.d
+++ b/gcc/testsuite/gdc.test/runnable/test11447a.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/a11447.d
 // PERMUTE_ARGS: -allinst
 
diff --git a/gcc/testsuite/gdc.test/runnable/test11447b.d b/gcc/testsuite/gdc.test/runnable/test11447b.d
index 1e76da7799a..5e37a5ab6b2 100644
--- a/gcc/testsuite/gdc.test/runnable/test11447b.d
+++ b/gcc/testsuite/gdc.test/runnable/test11447b.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/b11447.d
 // PERMUTE_ARGS: -allinst
 
diff --git a/gcc/testsuite/gdc.test/runnable/test11447c.d b/gcc/testsuite/gdc.test/runnable/test11447c.d
index ecec3e5c2c9..d3958fec4c0 100644
--- a/gcc/testsuite/gdc.test/runnable/test11447c.d
+++ b/gcc/testsuite/gdc.test/runnable/test11447c.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/c11447.d
 // REQUIRED_ARGS: -w
 // PERMUTE_ARGS: -allinst -debug -g
diff --git a/gcc/testsuite/gdc.test/runnable/test11863.d b/gcc/testsuite/gdc.test/runnable/test11863.d
index f6446aae725..9039fdb4ed2 100644
--- a/gcc/testsuite/gdc.test/runnable/test11863.d
+++ b/gcc/testsuite/gdc.test/runnable/test11863.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/std11863conv.d
 // EXTRA_FILES: imports/std11863bitmanip.d imports/std11863format.d
 
diff --git a/gcc/testsuite/gdc.test/runnable/test14901.d b/gcc/testsuite/gdc.test/runnable/test14901.d
index 73a357a4086..599344a86d6 100644
--- a/gcc/testsuite/gdc.test/runnable/test14901.d
+++ b/gcc/testsuite/gdc.test/runnable/test14901.d
@@ -1,7 +1,7 @@
 // REQUIRED_ARGS:
 // PERMUTE_ARGS: -unittest
 // EXTRA_SOURCES: imports/test14901a.d imports/test14901b.d imports/test14901c.d imports/test14901d.d
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 
 module test14901;
 
diff --git a/gcc/testsuite/gdc.test/runnable/test18868.d b/gcc/testsuite/gdc.test/runnable/test18868.d
index b0085c030e0..26d5c66c379 100644
--- a/gcc/testsuite/gdc.test/runnable/test18868.d
+++ b/gcc/testsuite/gdc.test/runnable/test18868.d
@@ -1,5 +1,5 @@
 /*
-COMPILE_SEPARATELY
+COMPILE_SEPARATELY:
 EXTRA_SOURCES: imports/test18868_a.d imports/test18868_fls.d
 PERMUTE_ARGS:
 */
diff --git a/gcc/testsuite/gdc.test/runnable/test27.d b/gcc/testsuite/gdc.test/runnable/test27.d
index b45c132620e..9c0a8d02ecb 100644
--- a/gcc/testsuite/gdc.test/runnable/test27.d
+++ b/gcc/testsuite/gdc.test/runnable/test27.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/test27a.d
 // PERMUTE_ARGS:
 
diff --git a/gcc/testsuite/gdc.test/runnable/test29.d b/gcc/testsuite/gdc.test/runnable/test29.d
index 03c81c65877..5ca1eef6013 100644
--- a/gcc/testsuite/gdc.test/runnable/test29.d
+++ b/gcc/testsuite/gdc.test/runnable/test29.d
@@ -1,5 +1,5 @@
 /*
-COMPILE_SEPARATELY
+COMPILE_SEPARATELY:
 EXTRA_SOURCES: imports/test29a.d imports/test29b.d
 PERMUTE_ARGS:
 RUN_OUTPUT:
diff --git a/gcc/testsuite/gdc.test/runnable/test31.d b/gcc/testsuite/gdc.test/runnable/test31.d
index b19366d240f..ea181047306 100644
--- a/gcc/testsuite/gdc.test/runnable/test31.d
+++ b/gcc/testsuite/gdc.test/runnable/test31.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/test31a.d
 // PERMUTE_ARGS:
 
diff --git a/gcc/testsuite/gdc.test/runnable/test32.d b/gcc/testsuite/gdc.test/runnable/test32.d
index 8340ad2a234..d98d46875a9 100644
--- a/gcc/testsuite/gdc.test/runnable/test32.d
+++ b/gcc/testsuite/gdc.test/runnable/test32.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/test32a.d
 // PERMUTE_ARGS:
 
diff --git a/gcc/testsuite/gdc.test/runnable/test38.d b/gcc/testsuite/gdc.test/runnable/test38.d
index 4c76e9f9f28..b38b9b911cc 100644
--- a/gcc/testsuite/gdc.test/runnable/test38.d
+++ b/gcc/testsuite/gdc.test/runnable/test38.d
@@ -1,5 +1,5 @@
 /*
-COMPILE_SEPARATELY
+COMPILE_SEPARATELY:
 EXTRA_SOURCES: imports/test38a.d
 PERMUTE_ARGS:
 RUN_OUTPUT:
diff --git a/gcc/testsuite/gdc.test/runnable/test46.d b/gcc/testsuite/gdc.test/runnable/test46.d
index 908cafb681a..f5089a75fec 100644
--- a/gcc/testsuite/gdc.test/runnable/test46.d
+++ b/gcc/testsuite/gdc.test/runnable/test46.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/test46b.d imports/test46a.d imports/test46c.d
 // PERMUTE_ARGS:
 
diff --git a/gcc/testsuite/gdc.test/runnable/test49.d b/gcc/testsuite/gdc.test/runnable/test49.d
index 641d196b59b..9ef1da4f7cc 100644
--- a/gcc/testsuite/gdc.test/runnable/test49.d
+++ b/gcc/testsuite/gdc.test/runnable/test49.d
@@ -1,5 +1,5 @@
 /*
-COMPILE_SEPARATELY
+COMPILE_SEPARATELY:
 EXTRA_SOURCES: imports/test49a.d
 PERMUTE_ARGS:
 RUN_OUTPUT:
diff --git a/gcc/testsuite/gdc.test/runnable/test57.d b/gcc/testsuite/gdc.test/runnable/test57.d
index 8c2b66294af..54cf67295c3 100644
--- a/gcc/testsuite/gdc.test/runnable/test57.d
+++ b/gcc/testsuite/gdc.test/runnable/test57.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/test57a.d imports/test57b.d
 // PERMUTE_ARGS:
 // REQUIRED_ARGS: -inline -release
diff --git a/gcc/testsuite/gdc.test/runnable/test7494.d b/gcc/testsuite/gdc.test/runnable/test7494.d
index 655d00a9ffa..ad9532aa2b8 100644
--- a/gcc/testsuite/gdc.test/runnable/test7494.d
+++ b/gcc/testsuite/gdc.test/runnable/test7494.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/test7494a.d
 // PERMUTE_ARGS:
 // REQUIRED_ARGS:
diff --git a/gcc/testsuite/gdc.test/runnable/test8997.d b/gcc/testsuite/gdc.test/runnable/test8997.d
index 9604e1264f4..cc021328779 100644
--- a/gcc/testsuite/gdc.test/runnable/test8997.d
+++ b/gcc/testsuite/gdc.test/runnable/test8997.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/test8997a.d
 
 module test8997;
diff --git a/gcc/testsuite/gdc.test/runnable/testmod1.d b/gcc/testsuite/gdc.test/runnable/testmod1.d
index 6d9aa9eff28..43d13d0b827 100644
--- a/gcc/testsuite/gdc.test/runnable/testmod1.d
+++ b/gcc/testsuite/gdc.test/runnable/testmod1.d
@@ -1,4 +1,4 @@
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/testmod1a.d imports/testmod1b.d
 // PERMUTE_ARGS:
 
diff --git a/gcc/testsuite/gdc.test/runnable/tls_dup.d b/gcc/testsuite/gdc.test/runnable/tls_dup.d
index e55f7e5a017..6acffb46bfd 100644
--- a/gcc/testsuite/gdc.test/runnable/tls_dup.d
+++ b/gcc/testsuite/gdc.test/runnable/tls_dup.d
@@ -1,7 +1,7 @@
 // NOTE: this is a dup of runnable/tls.d strictly to test the same code compiled
 // separately rather than together like the original is.
 
-// COMPILE_SEPARATELY
+// COMPILE_SEPARATELY:
 // EXTRA_SOURCES: imports/tlsa.d
 // PERMUTE_ARGS:
 
diff --git a/gcc/testsuite/gdc.test/runnable_cxx/cppa.d b/gcc/testsuite/gdc.test/runnable_cxx/cppa.d
index c60d6c66ef3..cd36bf22302 100644
--- a/gcc/testsuite/gdc.test/runnable_cxx/cppa.d
+++ b/gcc/testsuite/gdc.test/runnable_cxx/cppa.d
@@ -9,6 +9,9 @@
 
 // N.B MSVC doesn't have a C++11 switch, but it defaults to the latest fully-supported standard
 
+// Broken for unknown reasons since the OMF => MsCOFF switch
+// DISABLED: win32omf
+
 import core.stdc.stdio;
 import core.stdc.stdarg;
 import core.stdc.config;
diff --git a/libphobos/Makefile.in b/libphobos/Makefile.in
index a8f7e160742..2e9360a5238 100644
--- a/libphobos/Makefile.in
+++ b/libphobos/Makefile.in
@@ -15,7 +15,7 @@
 @SET_MAKE@
 
 # Makefile for the toplevel directory of the D Standard library.
-# Copyright (C) 2006-2021 Free Software Foundation, Inc.
+# Copyright (C) 2006-2022 Free Software Foundation, Inc.
 #
 # GCC is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 3aa798a543c..251d78de19b 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-759e60231a12482a1e1df5f891964e270dae0a1b
+dbd0c874a345438b8b4379a67525a933436d039a
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/druntime repository.
diff --git a/libphobos/libdruntime/Makefile.am b/libphobos/libdruntime/Makefile.am
index 2d0bd37babf..ba641315664 100644
--- a/libphobos/libdruntime/Makefile.am
+++ b/libphobos/libdruntime/Makefile.am
@@ -170,7 +170,7 @@ DRUNTIME_CSOURCES = core/stdc/errno_.c
 DRUNTIME_DSOURCES = core/atomic.d core/attribute.d core/bitop.d \
 	core/builtins.d core/checkedint.d core/cpuid.d core/demangle.d \
 	core/exception.d core/gc/config.d core/gc/gcinterface.d \
-	core/gc/registry.d core/internal/abort.d \
+	core/gc/registry.d core/int128.d core/internal/abort.d \
 	core/internal/array/appending.d core/internal/array/capacity.d \
 	core/internal/array/casting.d core/internal/array/comparison.d \
 	core/internal/array/concatenation.d core/internal/array/construction.d \
@@ -425,4 +425,4 @@ DRUNTIME_DSOURCES_WINDOWS = core/sys/windows/accctrl.d \
 	core/sys/windows/winuser.d core/sys/windows/winver.d \
 	core/sys/windows/wtsapi32.d core/sys/windows/wtypes.d
 
-DRUNTIME_DISOURCES = __main.di
+DRUNTIME_DISOURCES = __builtins.di __main.di
diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in
index bb936ddc1ff..1c64d35b164 100644
--- a/libphobos/libdruntime/Makefile.in
+++ b/libphobos/libdruntime/Makefile.in
@@ -15,7 +15,7 @@
 @SET_MAKE@
 
 # Makefile for the D runtime library.
-# Copyright (C) 2012-2021 Free Software Foundation, Inc.
+# Copyright (C) 2012-2022 Free Software Foundation, Inc.
 #
 # GCC is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -190,7 +190,7 @@ am__dirstamp = $(am__leading_dot)dirstamp
 am__objects_1 = core/atomic.lo core/attribute.lo core/bitop.lo \
 	core/builtins.lo core/checkedint.lo core/cpuid.lo \
 	core/demangle.lo core/exception.lo core/gc/config.lo \
-	core/gc/gcinterface.lo core/gc/registry.lo \
+	core/gc/gcinterface.lo core/gc/registry.lo core/int128.lo \
 	core/internal/abort.lo core/internal/array/appending.lo \
 	core/internal/array/capacity.lo core/internal/array/casting.lo \
 	core/internal/array/comparison.lo \
@@ -834,7 +834,7 @@ DRUNTIME_CSOURCES = core/stdc/errno_.c
 DRUNTIME_DSOURCES = core/atomic.d core/attribute.d core/bitop.d \
 	core/builtins.d core/checkedint.d core/cpuid.d core/demangle.d \
 	core/exception.d core/gc/config.d core/gc/gcinterface.d \
-	core/gc/registry.d core/internal/abort.d \
+	core/gc/registry.d core/int128.d core/internal/abort.d \
 	core/internal/array/appending.d core/internal/array/capacity.d \
 	core/internal/array/casting.d core/internal/array/comparison.d \
 	core/internal/array/concatenation.d core/internal/array/construction.d \
@@ -1089,7 +1089,7 @@ DRUNTIME_DSOURCES_WINDOWS = core/sys/windows/accctrl.d \
 	core/sys/windows/winuser.d core/sys/windows/winver.d \
 	core/sys/windows/wtsapi32.d core/sys/windows/wtypes.d
 
-DRUNTIME_DISOURCES = __main.di
+DRUNTIME_DISOURCES = __builtins.di __main.di
 all: all-am
 
 .SUFFIXES:
@@ -1187,6 +1187,7 @@ core/gc/$(am__dirstamp):
 core/gc/config.lo: core/gc/$(am__dirstamp)
 core/gc/gcinterface.lo: core/gc/$(am__dirstamp)
 core/gc/registry.lo: core/gc/$(am__dirstamp)
+core/int128.lo: core/$(am__dirstamp)
 core/internal/$(am__dirstamp):
 	@$(MKDIR_P) core/internal
 	@: > core/internal/$(am__dirstamp)
diff --git a/libphobos/libdruntime/__builtins.di b/libphobos/libdruntime/__builtins.di
new file mode 100644
index 00000000000..cd64881529e
--- /dev/null
+++ b/libphobos/libdruntime/__builtins.di
@@ -0,0 +1,40 @@
+/* This D file is implicitly imported by all ImportC source files.
+ * It provides definitions for C compiler builtin functions and declarations.
+ * The purpose is to make it unnecessary to hardwire them into the compiler.
+ * As the leading double underscore suggests, this is for internal use only.
+ *
+ * Copyright: Copyright Digital Mars 2022
+ * License:   $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ * Source: $(DRUNTIMESRC __builtins.d)
+ */
+
+
+module __builtins;
+
+/* gcc relies on internal __builtin_xxxx functions and templates to
+ * accomplish <stdarg.h>. D does the same thing with templates in core.stdc.stdarg.
+ * Here, we redirect the gcc builtin declarations to the equivalent
+ * ones in core.stdc.stdarg, thereby avoiding having to hardware them
+ * into the D compiler.
+ */
+
+import core.stdc.stdarg;
+
+alias va_list = core.stdc.stdarg.va_list;
+
+version (Posix)
+{
+    version (X86_64)
+        alias __va_list_tag = core.stdc.stdarg.__va_list_tag;
+}
+
+alias __builtin_va_start = core.stdc.stdarg.va_start;
+
+alias __builtin_va_end = core.stdc.stdarg.va_end;
+
+alias __builtin_va_copy = core.stdc.stdarg.va_copy;
+
+/* dmd's ImportC rewrites __builtin_va_arg into an instantiation of va_arg
+ */
+alias va_arg = core.stdc.stdarg.va_arg;
diff --git a/libphobos/libdruntime/core/demangle.d b/libphobos/libdruntime/core/demangle.d
index 1915fb0844a..930e0cd9c24 100644
--- a/libphobos/libdruntime/core/demangle.d
+++ b/libphobos/libdruntime/core/demangle.d
@@ -2471,7 +2471,7 @@ private template hasPlainMangling(FT) if (is(FT == function))
 {
     enum lnk = __traits(getLinkage, FT);
     // C || Windows
-    enum hasPlainMangling = lnk == "C" || lnk == "Windows";
+    enum hasPlainMangling = lnk == "C" || lnk == "Windows" || lnk == "System";
 }
 
 @safe pure nothrow unittest
diff --git a/libphobos/libdruntime/core/int128.d b/libphobos/libdruntime/core/int128.d
new file mode 100644
index 00000000000..aad2cf23942
--- /dev/null
+++ b/libphobos/libdruntime/core/int128.d
@@ -0,0 +1,919 @@
+/* 128 bit integer arithmetic.
+ *
+ * Not optimized for speed.
+ *
+ * Copyright: Copyright D Language Foundation 2022.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Walter Bright
+ * Source:    $(DRUNTIMESRC core/_int128.d)
+ */
+
+module core.int128;
+
+nothrow:
+@safe:
+@nogc:
+
+alias I = long;
+alias U = ulong;
+enum Ubits = uint(U.sizeof * 8);
+
+align(16) struct Cent
+{
+    U lo;      // low 64 bits
+    U hi;      // high 64 bits
+}
+
+enum One = Cent(1);
+enum Zero = Cent();
+enum MinusOne = neg(One);
+
+/*****************************
+ * Test against 0
+ * Params:
+ *      c = Cent to test
+ * Returns:
+ *      true if != 0
+ */
+pure
+bool tst(Cent c)
+{
+    return c.hi || c.lo;
+}
+
+
+/*****************************
+ * Complement
+ * Params:
+ *      c = Cent to complement
+ * Returns:
+ *      complemented value
+ */
+pure
+Cent com(Cent c)
+{
+    c.lo = ~c.lo;
+    c.hi = ~c.hi;
+    return c;
+}
+
+/*****************************
+ * Negate
+ * Params:
+ *      c = Cent to negate
+ * Returns:
+ *      negated value
+ */
+pure
+Cent neg(Cent c)
+{
+    if (c.lo == 0)
+        c.hi = -c.hi;
+    else
+    {
+        c.lo = -c.lo;
+        c.hi = ~c.hi;
+    }
+    return c;
+}
+
+/*****************************
+ * Increment
+ * Params:
+ *      c = Cent to increment
+ * Returns:
+ *      incremented value
+ */
+pure
+Cent inc(Cent c)
+{
+    return add(c, One);
+}
+
+/*****************************
+ * Decrement
+ * Params:
+ *      c = Cent to decrement
+ * Returns:
+ *      incremented value
+ */
+pure
+Cent dec(Cent c)
+{
+    return sub(c, One);
+}
+
+/*****************************
+ * Shift left one bit
+ * Params:
+ *      c = Cent to shift
+ * Returns:
+ *      shifted value
+ */
+pure
+Cent shl1(Cent c)
+{
+    c.hi = (c.hi << 1) | (cast(I)c.lo < 0);
+    c.lo <<= 1;
+    return c;
+}
+
+/*****************************
+ * Unsigned shift right one bit
+ * Params:
+ *      c = Cent to shift
+ * Returns:
+ *      shifted value
+ */
+pure
+Cent shr1(Cent c)
+{
+    c.lo = (c.lo >> 1) | ((c.hi & 1) << (Ubits - 1));
+    c.hi >>= 1;
+    return c;
+}
+
+
+/*****************************
+ * Arithmetic shift right one bit
+ * Params:
+ *      c = Cent to shift
+ * Returns:
+ *      shifted value
+ */
+pure
+Cent sar1(Cent c)
+{
+    c.lo = (c.lo >> 1) | ((c.hi & 1) << (Ubits - 1));
+    c.hi = cast(I)c.hi >> 1;
+    return c;
+}
+
+/*****************************
+ * Shift left n bits
+ * Params:
+ *      c = Cent to shift
+ *      n = number of bits to shift
+ * Returns:
+ *      shifted value
+ */
+pure
+Cent shl(Cent c, uint n)
+{
+    if (n >= Ubits * 2)
+        return Zero;
+
+    if (n >= Ubits)
+    {
+        c.hi = c.lo << (n - Ubits);
+        c.lo = 0;
+    }
+    else
+    {
+        c.hi = ((c.hi << n) | (c.lo >> (Ubits - n - 1) >> 1));
+        c.lo = c.lo << n;
+    }
+    return c;
+}
+
+/*****************************
+ * Unsigned shift right n bits
+ * Params:
+ *      c = Cent to shift
+ *      n = number of bits to shift
+ * Returns:
+ *      shifted value
+ */
+pure
+Cent shr(Cent c, uint n)
+{
+    if (n >= Ubits * 2)
+        return Zero;
+
+    if (n >= Ubits)
+    {
+        c.lo = c.hi >> (n - Ubits);
+        c.hi = 0;
+    }
+    else
+    {
+        c.lo = ((c.lo >> n) | (c.hi << (Ubits - n - 1) << 1));
+        c.hi = c.hi >> n;
+    }
+    return c;
+}
+
+/*****************************
+ * Arithmetic shift right n bits
+ * Params:
+ *      c = Cent to shift
+ *      n = number of bits to shift
+ * Returns:
+ *      shifted value
+ */
+pure
+Cent sar(Cent c, uint n)
+{
+    const signmask = -(c.hi >> (Ubits - 1));
+    const signshift = (Ubits * 2) - n;
+    c = shr(c, n);
+
+    // Sign extend all bits beyond the precision of Cent.
+    if (n >= Ubits * 2)
+    {
+        c.hi = signmask;
+        c.lo = signmask;
+    }
+    else if (signshift >= Ubits * 2)
+    {
+    }
+    else if (signshift >= Ubits)
+    {
+        c.hi &= ~(U.max << (signshift - Ubits));
+        c.hi |= signmask << (signshift - Ubits);
+    }
+    else
+    {
+        c.hi = signmask;
+        c.lo &= ~(U.max << signshift);
+        c.lo |= signmask << signshift;
+    }
+    return c;
+}
+
+/*****************************
+ * Rotate left one bit
+ * Params:
+ *      c = Cent to rotate
+ * Returns:
+ *      rotated value
+ */
+pure
+Cent rol1(Cent c)
+{
+    int carry = cast(I)c.hi < 0;
+
+    c.hi = (c.hi << 1) | (cast(I)c.lo < 0);
+    c.lo = (c.lo << 1) | carry;
+    return c;
+}
+
+/*****************************
+ * Rotate right one bit
+ * Params:
+ *      c = Cent to rotate
+ * Returns:
+ *      rotated value
+ */
+pure
+Cent ror1(Cent c)
+{
+    int carry = c.lo & 1;
+    c.lo = (c.lo >> 1) | (cast(U)(c.hi & 1) << (Ubits - 1));
+    c.hi = (c.hi >> 1) | (cast(U)carry << (Ubits - 1));
+    return c;
+}
+
+
+/*****************************
+ * Rotate left n bits
+ * Params:
+ *      c = Cent to rotate
+ *      n = number of bits to rotate
+ * Returns:
+ *      rotated value
+ */
+pure
+Cent rol(Cent c, uint n)
+{
+    n &= Ubits * 2 - 1;
+    Cent l = shl(c, n);
+    Cent r = shr(c, Ubits * 2 - n);
+    return or(l, r);
+}
+
+/*****************************
+ * Rotate right n bits
+ * Params:
+ *      c = Cent to rotate
+ *      n = number of bits to rotate
+ * Returns:
+ *      rotated value
+ */
+pure
+Cent ror(Cent c, uint n)
+{
+    n &= Ubits * 2 - 1;
+    Cent r = shr(c, n);
+    Cent l = shl(c, Ubits * 2 - n);
+    return or(r, l);
+}
+
+/****************************
+ * And c1 & c2.
+ * Params:
+ *      c1 = operand 1
+ *      c2 = operand 2
+ * Returns:
+ *      c1 & c2
+ */
+pure
+Cent and(Cent c1, Cent c2)
+{
+    return Cent(c1.lo & c2.lo, c1.hi & c2.hi);
+}
+
+/****************************
+ * Or c1 | c2.
+ * Params:
+ *      c1 = operand 1
+ *      c2 = operand 2
+ * Returns:
+ *      c1 | c2
+ */
+pure
+Cent or(Cent c1, Cent c2)
+{
+    return Cent(c1.lo | c2.lo, c1.hi | c2.hi);
+}
+
+/****************************
+ * Xor c1 ^ c2.
+ * Params:
+ *      c1 = operand 1
+ *      c2 = operand 2
+ * Returns:
+ *      c1 ^ c2
+ */
+pure
+Cent xor(Cent c1, Cent c2)
+{
+    return Cent(c1.lo ^ c2.lo, c1.hi ^ c2.hi);
+}
+
+/****************************
+ * Add c1 to c2.
+ * Params:
+ *      c1 = operand 1
+ *      c2 = operand 2
+ * Returns:
+ *      c1 + c2
+ */
+pure
+Cent add(Cent c1, Cent c2)
+{
+    U r = cast(U)(c1.lo + c2.lo);
+    return Cent(r, cast(U)(c1.hi + c2.hi + (r < c1.lo)));
+}
+
+/****************************
+ * Subtract c2 from c1.
+ * Params:
+ *      c1 = operand 1
+ *      c2 = operand 2
+ * Returns:
+ *      c1 - c2
+ */
+pure
+Cent sub(Cent c1, Cent c2)
+{
+    return add(c1, neg(c2));
+}
+
+/****************************
+ * Multiply c1 * c2.
+ * Params:
+ *      c1 = operand 1
+ *      c2 = operand 2
+ * Returns:
+ *      c1 * c2
+ */
+pure
+Cent mul(Cent c1, Cent c2)
+{
+    enum mulmask = (1UL << (Ubits / 2)) - 1;
+    enum mulshift = Ubits / 2;
+
+    // This algorithm splits the operands into 4 words, then computes and sums
+    // the partial products of each part.
+    const c2l0 = c2.lo & mulmask;
+    const c2l1 = c2.lo >> mulshift;
+    const c2h0 = c2.hi & mulmask;
+    const c2h1 = c2.hi >> mulshift;
+
+    const c1l0 = c1.lo & mulmask;
+    U r0 = c1l0 * c2l0;
+    U r1 = c1l0 * c2l1 + (r0 >> mulshift);
+    U r2 = c1l0 * c2h0 + (r1 >> mulshift);
+    U r3 = c1l0 * c2h1 + (r2 >> mulshift);
+
+    const c1l1 = c1.lo >> mulshift;
+    r1 = c1l1 * c2l0 + (r1 & mulmask);
+    r2 = c1l1 * c2l1 + (r2 & mulmask) + (r1 >> mulshift);
+    r3 = c1l1 * c2h0 + (r3 & mulmask) + (r2 >> mulshift);
+
+    const c1h0 = c1.hi & mulmask;
+    r2 = c1h0 * c2l0 + (r2 & mulmask);
+    r3 = c1h0 * c2l1 + (r3 & mulmask) + (r2 >> mulshift);
+
+    const c1h1 = c1.hi >> mulshift;
+    r3 = c1h1 * c2l0 + (r3 & mulmask);
+
+    return Cent((r0 & mulmask) + (r1 & mulmask) * (mulmask + 1),
+                (r2 & mulmask) + (r3 & mulmask) * (mulmask + 1));
+
+}
+
+
+/****************************
+ * Unsigned divide c1 / c2.
+ * Params:
+ *      c1 = dividend
+ *      c2 = divisor
+ * Returns:
+ *      quotient c1 / c2
+ */
+pure
+Cent udiv(Cent c1, Cent c2)
+{
+    Cent modulus;
+    return udivmod(c1, c2, modulus);
+}
+
+/****************************
+ * Unsigned divide c1 / c2. The remainder after division is stored to modulus.
+ * Params:
+ *      c1 = dividend
+ *      c2 = divisor
+ *      modulus = set to c1 % c2
+ * Returns:
+ *      quotient c1 / c2
+ */
+pure
+Cent udivmod(Cent c1, Cent c2, out Cent modulus)
+{
+    //printf("udiv c1(%llx,%llx) c2(%llx,%llx)\n", c1.lo, c1.hi, c2.lo, c2.hi);
+    // Based on "Unsigned Doubleword Division" in Hacker's Delight
+    import core.bitop;
+
+    // Divides a 128-bit dividend by a 64-bit divisor.
+    // The result must fit in 64 bits.
+    static U udivmod128_64(Cent c1, U c2, out U modulus)
+    {
+        // We work in base 2^^32
+        enum base = 1UL << 32;
+        enum divmask = (1UL << (Ubits / 2)) - 1;
+        enum divshift = Ubits / 2;
+
+        // Check for overflow and divide by 0
+        if (c1.hi >= c2)
+        {
+            modulus = 0UL;
+            return ~0UL;
+        }
+
+        // Computes [num1 num0] / den
+        static uint udiv96_64(U num1, uint num0, U den)
+        {
+            // Extract both digits of the denominator
+            const den1 = cast(uint)(den >> divshift);
+            const den0 = cast(uint)(den & divmask);
+            // Estimate ret as num1 / den1, and then correct it
+            U ret = num1 / den1;
+            const t2 = (num1 % den1) * base + num0;
+            const t1 = ret * den0;
+            if (t1 > t2)
+                ret -= (t1 - t2 > den) ? 2 : 1;
+            return cast(uint)ret;
+        }
+
+        // Determine the normalization factor. We multiply c2 by this, so that its leading
+        // digit is at least half base. In binary this means just shifting left by the number
+        // of leading zeros, so that there's a 1 in the MSB.
+        // We also shift number by the same amount. This cannot overflow because c1.hi < c2.
+        const shift = (Ubits - 1) - bsr(c2);
+        c2 <<= shift;
+        U num2 = c1.hi;
+        num2 <<= shift;
+        num2 |= (c1.lo >> (-shift & 63)) & (-cast(I)shift >> 63);
+        c1.lo <<= shift;
+
+        // Extract the low digits of the numerator (after normalizing)
+        const num1 = cast(uint)(c1.lo >> divshift);
+        const num0 = cast(uint)(c1.lo & divmask);
+
+        // Compute q1 = [num2 num1] / c2
+        const q1 = udiv96_64(num2, num1, c2);
+        // Compute the true (partial) remainder
+        const rem = num2 * base + num1 - q1 * c2;
+        // Compute q0 = [rem num0] / c2
+        const q0 = udiv96_64(rem, num0, c2);
+
+        modulus = (rem * base + num0 - q0 * c2) >> shift;
+        return (cast(U)q1 << divshift) | q0;
+    }
+
+    // Special cases
+    if (!tst(c2))
+    {
+        // Divide by zero
+        modulus = Zero;
+        return com(modulus);
+    }
+    if (c1.hi == 0 && c2.hi == 0)
+    {
+        // Single precision divide
+        modulus = Cent(c1.lo % c2.lo);
+        return Cent(c1.lo / c2.lo);
+    }
+    if (c1.hi == 0)
+    {
+        // Numerator is smaller than the divisor
+        modulus = c1;
+        return Zero;
+    }
+    if (c2.hi == 0)
+    {
+        // Divisor is a 64-bit value, so we just need one 128/64 division.
+        // If c1 / c2 would overflow, break c1 up into two halves.
+        const q1 = (c1.hi < c2.lo) ? 0 : (c1.hi / c2.lo);
+        if (q1)
+            c1.hi = c1.hi % c2.lo;
+        U rem;
+        const q0 = udivmod128_64(c1, c2.lo, rem);
+        modulus = Cent(rem);
+        return Cent(q0, q1);
+    }
+
+    // Full cent precision division.
+    // Here c2 >= 2^^64
+    // We know that c2.hi != 0, so count leading zeros is OK
+    // We have 0 <= shift <= 63
+    const shift = (Ubits - 1) - bsr(c2.hi);
+
+    // Normalize the divisor so its MSB is 1
+    // v1 = (c2 << shift) >> 64
+    U v1 = shl(c2, shift).hi;
+
+    // To ensure no overflow.
+    Cent u1 = shr1(c1);
+
+    // Get quotient from divide unsigned operation.
+    U rem_ignored;
+    const q1 = udivmod128_64(u1, v1, rem_ignored);
+
+    // Undo normalization and division of c1 by 2.
+    Cent quotient = shr(shl(Cent(q1), shift), 63);
+
+    // Make quotient correct or too small by 1
+    if (tst(quotient))
+        quotient = dec(quotient);
+
+    // Now quotient is correct.
+    // Compute rem = c1 - (quotient * c2);
+    Cent rem = sub(c1, mul(quotient, c2));
+
+    // Check if remainder is larger than the divisor
+    if (uge(rem, c2))
+    {
+        // Increment quotient
+        quotient = inc(quotient);
+        // Subtract c2 from remainder
+        rem = sub(rem, c2);
+    }
+    modulus = rem;
+    //printf("quotient "); print(quotient);
+    //printf("modulus  "); print(modulus);
+    return quotient;
+}
+
+
+/****************************
+ * Signed divide c1 / c2.
+ * Params:
+ *      c1 = dividend
+ *      c2 = divisor
+ * Returns:
+ *      quotient c1 / c2
+ */
+pure
+Cent div(Cent c1, Cent c2)
+{
+    Cent modulus;
+    return divmod(c1, c2, modulus);
+}
+
+/****************************
+ * Signed divide c1 / c2. The remainder after division is stored to modulus.
+ * Params:
+ *      c1 = dividend
+ *      c2 = divisor
+ *      modulus = set to c1 % c2
+ * Returns:
+ *      quotient c1 / c2
+ */
+pure
+Cent divmod(Cent c1, Cent c2, out Cent modulus)
+{
+    /* Muck about with the signs so we can use the unsigned divide
+     */
+    if (cast(I)c1.hi < 0)
+    {
+        if (cast(I)c2.hi < 0)
+        {
+            Cent r = udivmod(neg(c1), neg(c2), modulus);
+            modulus = neg(modulus);
+            return r;
+        }
+        Cent r = neg(udivmod(neg(c1), c2, modulus));
+        modulus = neg(modulus);
+        return r;
+    }
+    else if (cast(I)c2.hi < 0)
+    {
+        return neg(udivmod(c1, neg(c2), modulus));
+    }
+    else
+        return udivmod(c1, c2, modulus);
+}
+
+/****************************
+ * If c1 > c2 unsigned
+ * Params:
+ *      c1 = operand 1
+ *      c2 = operand 2
+ * Returns:
+ *      true if c1 > c2
+ */
+pure
+bool ugt(Cent c1, Cent c2)
+{
+    return (c1.hi == c2.hi) ? (c1.lo > c2.lo) : (c1.hi > c2.hi);
+}
+
+/****************************
+ * If c1 >= c2 unsigned
+ * Params:
+ *      c1 = operand 1
+ *      c2 = operand 2
+ * Returns:
+ *      true if c1 >= c2
+ */
+pure
+bool uge(Cent c1, Cent c2)
+{
+    return !ugt(c2, c1);
+}
+
+/****************************
+ * If c1 < c2 unsigned
+ * Params:
+ *      c1 = operand 1
+ *      c2 = operand 2
+ * Returns:
+ *      true if c1 < c2
+ */
+pure
+bool ult(Cent c1, Cent c2)
+{
+    return ugt(c2, c1);
+}
+
+/****************************
+ * If c1 <= c2 unsigned
+ * Params:
+ *      c1 = operand 1
+ *      c2 = operand 2
+ * Returns:
+ *      true if c1 <= c2
+ */
+pure
+bool ule(Cent c1, Cent c2)
+{
+    return !ugt(c1, c2);
+}
+
+/****************************
+ * If c1 > c2 signed
+ * Params:
+ *      c1 = operand 1
+ *      c2 = operand 2
+ * Returns:
+ *      true if c1 > c2
+ */
+pure
+bool gt(Cent c1, Cent c2)
+{
+    return (c1.hi == c2.hi)
+        ? (c1.lo > c2.lo)
+        : (cast(I)c1.hi > cast(I)c2.hi);
+}
+
+/****************************
+ * If c1 >= c2 signed
+ * Params:
+ *      c1 = operand 1
+ *      c2 = operand 2
+ * Returns:
+ *      true if c1 >= c2
+ */
+pure
+bool ge(Cent c1, Cent c2)
+{
+    return !gt(c2, c1);
+}
+
+/****************************
+ * If c1 < c2 signed
+ * Params:
+ *      c1 = operand 1
+ *      c2 = operand 2
+ * Returns:
+ *      true if c1 < c2
+ */
+pure
+bool lt(Cent c1, Cent c2)
+{
+    return gt(c2, c1);
+}
+
+/****************************
+ * If c1 <= c2 signed
+ * Params:
+ *      c1 = operand 1
+ *      c2 = operand 2
+ * Returns:
+ *      true if c1 <= c2
+ */
+pure
+bool le(Cent c1, Cent c2)
+{
+    return !gt(c1, c2);
+}
+
+/*******************************************************/
+
+version (unittest)
+{
+    version (none)
+    {
+        import core.stdc.stdio;
+
+        @trusted
+        void print(Cent c)
+        {
+            printf("%lld, %lld\n", cast(ulong)c.lo, cast(ulong)c.hi);
+            printf("x%llx, x%llx\n", cast(ulong)c.lo, cast(ulong)c.hi);
+        }
+    }
+}
+
+unittest
+{
+    const C0 = Zero;
+    const C1 = One;
+    const C2 = Cent(2);
+    const C3 = Cent(3);
+    const C5 = Cent(5);
+    const C10 = Cent(10);
+    const C20 = Cent(20);
+    const C30 = Cent(30);
+    const C100 = Cent(100);
+
+    const Cm1 =  neg(One);
+    const Cm3 =  neg(C3);
+    const Cm10 = neg(C10);
+
+    const C3_1 = Cent(1,3);
+    const C3_2 = Cent(2,3);
+    const C4_8  = Cent(8, 4);
+    const C5_0  = Cent(0, 5);
+    const C7_1 = Cent(1,7);
+    const C7_9 = Cent(9,7);
+    const C9_3 = Cent(3,9);
+    const C10_0 = Cent(0,10);
+    const C10_1 = Cent(1,10);
+    const C10_3 = Cent(3,10);
+    const C11_3 = Cent(3,11);
+    const C20_0 = Cent(0,20);
+    const C90_30 = Cent(30,90);
+
+    const Cm10_0 = inc(com(C10_0)); // Cent(0, -10);
+    const Cm10_1 = inc(com(C10_1)); // Cent(-1, -11);
+    const Cm10_3 = inc(com(C10_3)); // Cent(-3, -11);
+
+    enum Cs_3 = Cent(3, I.min);
+
+    const Cbig_1 = Cent(0xa3ccac1832952398, 0xc3ac542864f652f8);
+    const Cbig_2 = Cent(0x5267b85f8a42fc20, 0);
+    const Cbig_3 = Cent(0xf0000000ffffffff, 0);
+
+    /************************/
+
+    assert( ugt(C1, C0) );
+    assert( ult(C1, C2) );
+    assert( uge(C1, C0) );
+    assert( ule(C1, C2) );
+
+    assert( !ugt(C0, C1) );
+    assert( !ult(C2, C1) );
+    assert( !uge(C0, C1) );
+    assert( !ule(C2, C1) );
+
+    assert( !ugt(C1, C1) );
+    assert( !ult(C1, C1) );
+    assert( uge(C1, C1) );
+    assert( ule(C2, C2) );
+
+    assert( ugt(C10_3, C10_1) );
+    assert( ugt(C11_3, C10_3) );
+    assert( !ugt(C9_3, C10_3) );
+    assert( !ugt(C9_3, C9_3) );
+
+    assert( gt(C2, C1) );
+    assert( !gt(C1, C2) );
+    assert( !gt(C1, C1) );
+    assert( gt(C0, Cm1) );
+    assert( gt(Cm1, neg(C10)));
+    assert( !gt(Cm1, Cm1) );
+    assert( !gt(Cm1, C0) );
+
+    assert( !lt(C2, C1) );
+    assert( !le(C2, C1) );
+    assert( ge(C2, C1) );
+
+    assert(neg(C10_0) == Cm10_0);
+    assert(neg(C10_1) == Cm10_1);
+    assert(neg(C10_3) == Cm10_3);
+
+    assert(add(C7_1,C3_2) == C10_3);
+    assert(sub(C1,C2) == Cm1);
+
+    assert(inc(C3_1) == C3_2);
+    assert(dec(C3_2) == C3_1);
+
+    assert(shl(C10,0) == C10);
+    assert(shl(C10,Ubits) == C10_0);
+    assert(shl(C10,1) == C20);
+    assert(shl(C10,Ubits * 2) == C0);
+    assert(shr(C10_0,0) == C10_0);
+    assert(shr(C10_0,Ubits) == C10);
+    assert(shr(C10_0,Ubits - 1) == C20);
+    assert(shr(C10_0,Ubits + 1) == C5);
+    assert(shr(C10_0,Ubits * 2) == C0);
+    assert(sar(C10_0,0) == C10_0);
+    assert(sar(C10_0,Ubits) == C10);
+    assert(sar(C10_0,Ubits - 1) == C20);
+    assert(sar(C10_0,Ubits + 1) == C5);
+    assert(sar(C10_0,Ubits * 2) == C0);
+    assert(sar(Cm1,Ubits * 2) == Cm1);
+
+    assert(shl1(C10) == C20);
+    assert(shr1(C10_0) == C5_0);
+    assert(sar1(C10_0) == C5_0);
+    assert(sar1(Cm1) == Cm1);
+
+    Cent modulus;
+
+    assert(udiv(C10,C2) == C5);
+    assert(udivmod(C10,C2, modulus) ==  C5);   assert(modulus == C0);
+    assert(udivmod(C10,C3, modulus) ==  C3);   assert(modulus == C1);
+    assert(udivmod(C10,C0, modulus) == Cm1);   assert(modulus == C0);
+    assert(udivmod(C2,C90_30, modulus) == C0); assert(modulus == C2);
+    assert(udiv(mul(C90_30, C2), C2) == C90_30);
+    assert(udiv(mul(C90_30, C2), C90_30) == C2);
+
+    assert(div(C10,C3) == C3);
+    assert(divmod( C10,  C3, modulus) ==  C3); assert(modulus ==  C1);
+    assert(divmod(Cm10,  C3, modulus) == Cm3); assert(modulus == Cm1);
+    assert(divmod( C10, Cm3, modulus) == Cm3); assert(modulus ==  C1);
+    assert(divmod(Cm10, Cm3, modulus) ==  C3); assert(modulus == Cm1);
+    assert(divmod(C2, C90_30, modulus) == C0); assert(modulus == C2);
+    assert(div(mul(C90_30, C2), C2) == C90_30);
+    assert(div(mul(C90_30, C2), C90_30) == C2);
+
+    assert(divmod(Cbig_1, Cbig_2, modulus) == Cent(0x4496aa309d4d4a2f, U.max));
+    assert(modulus == Cent(0xd83203d0fdc799b8, U.max));
+    assert(udivmod(Cbig_1, Cbig_2, modulus) == Cent(0x5fe0e9bace2bedad, 2));
+    assert(modulus == Cent(0x2c923125a68721f8, 0));
+    assert(div(Cbig_1, Cbig_3) == Cent(0xbfa6c02b5aff8b86, U.max));
+    assert(udiv(Cbig_1, Cbig_3) == Cent(0xd0b7d13b48cb350f, 0));
+
+    assert(mul(Cm10, C1) == Cm10);
+    assert(mul(C1, Cm10) == Cm10);
+    assert(mul(C9_3, C10) == C90_30);
+    assert(mul(Cs_3, C10) == C30);
+    assert(mul(Cm10, Cm10) == C100);
+
+    assert( or(C4_8, C3_1) == C7_9);
+    assert(and(C4_8, C7_9) == C4_8);
+    assert(xor(C4_8, C7_9) == C3_1);
+
+    assert(rol(Cm1,  1) == Cm1);
+    assert(ror(Cm1, 45) == Cm1);
+    assert(rol(ror(C7_9, 5), 5) == C7_9);
+    assert(rol(C7_9, 1) == rol1(C7_9));
+    assert(ror(C7_9, 1) == ror1(C7_9));
+}
+
+
diff --git a/libphobos/libdruntime/core/internal/gc/impl/conservative/gc.d b/libphobos/libdruntime/core/internal/gc/impl/conservative/gc.d
index a731d6f7ae4..87c45fb2872 100644
--- a/libphobos/libdruntime/core/internal/gc/impl/conservative/gc.d
+++ b/libphobos/libdruntime/core/internal/gc/impl/conservative/gc.d
@@ -4571,7 +4571,7 @@ string debugTypeName(const(TypeInfo) ti) nothrow
         else
             return debugTypeName(ci.next);
     else
-        name = ti.classinfo.name;
+        name = typeid(ti).name;
     return name;
 }
 
diff --git a/libphobos/libdruntime/core/lifetime.d b/libphobos/libdruntime/core/lifetime.d
index 9a99f2da02a..091269ac9a1 100644
--- a/libphobos/libdruntime/core/lifetime.d
+++ b/libphobos/libdruntime/core/lifetime.d
@@ -2108,6 +2108,65 @@ private T trustedMoveImpl(T)(return scope ref T source) @trusted
     move(x, x);
 }
 
+private enum bool hasContextPointers(T) = {
+    static if (__traits(isStaticArray, T))
+    {
+        return hasContextPointers!(typeof(T.init[0]));
+    }
+    else static if (is(T == struct))
+    {
+        import core.internal.traits : anySatisfy;
+        return __traits(isNested, T) || anySatisfy!(hasContextPointers, typeof(T.tupleof));
+    }
+    else return false;
+} ();
+
+@safe @nogc nothrow pure unittest
+{
+    static assert(!hasContextPointers!int);
+    static assert(!hasContextPointers!(void*));
+
+    static struct S {}
+    static assert(!hasContextPointers!S);
+    static assert(!hasContextPointers!(S[1]));
+
+    struct Nested
+    {
+        void foo() {}
+    }
+
+    static assert(hasContextPointers!Nested);
+    static assert(hasContextPointers!(Nested[1]));
+
+    static struct OneLevel
+    {
+        int before;
+        Nested n;
+        int after;
+    }
+
+    static assert(hasContextPointers!OneLevel);
+    static assert(hasContextPointers!(OneLevel[1]));
+
+    static struct TwoLevels
+    {
+        int before;
+        OneLevel o;
+        int after;
+    }
+
+    static assert(hasContextPointers!TwoLevels);
+    static assert(hasContextPointers!(TwoLevels[1]));
+
+    union U
+    {
+        Nested n;
+    }
+
+    // unions can have false positives, so this query ignores them
+    static assert(!hasContextPointers!U);
+}
+
 // target must be first-parameter, because in void-functions DMD + dip1000 allows it to take the place of a return-scope
 private void moveEmplaceImpl(T)(scope ref T target, return scope ref T source)
 {
@@ -2119,9 +2178,10 @@ private void moveEmplaceImpl(T)(scope ref T target, return scope ref T source)
 //              "Cannot move object with internal pointer unless `opPostMove` is defined.");
 //    }
 
+    import core.internal.traits : hasElaborateAssign, isAssignable, hasElaborateMove,
+                                  hasElaborateDestructor, hasElaborateCopyConstructor;
     static if (is(T == struct))
     {
-        import core.internal.traits;
 
         //  Unsafe when compiling without -preview=dip1000
         assert((() @trusted => &source !is &target)(), "source and target must not be identical");
@@ -2141,29 +2201,36 @@ private void moveEmplaceImpl(T)(scope ref T target, return scope ref T source)
         // object in order to avoid double freeing and undue aliasing
         static if (hasElaborateDestructor!T || hasElaborateCopyConstructor!T)
         {
-            // If T is nested struct, keep original context pointer
-            static if (__traits(isNested, T))
-                enum sz = T.sizeof - (void*).sizeof;
-            else
-                enum sz = T.sizeof;
-
+            // If there are members that are nested structs, we must take care
+            // not to erase any context pointers, so we might have to recurse
             static if (__traits(isZeroInit, T))
+                wipe(source);
+            else
+                wipe(source, ref () @trusted { return *cast(immutable(T)*) __traits(initSymbol, T).ptr; } ());
+        }
+    }
+    else static if (__traits(isStaticArray, T))
+    {
+        static if (T.length)
+        {
+            static if (!hasElaborateMove!T &&
+                       !hasElaborateDestructor!T &&
+                       !hasElaborateCopyConstructor!T)
             {
-                import core.stdc.string : memset;
-                () @trusted { memset(&source, 0, sz); }();
+                // Single blit if no special per-instance handling is required
+                () @trusted
+                {
+                    assert(source.ptr !is target.ptr, "source and target must not be identical");
+                    *cast(ubyte[T.sizeof]*) &target = *cast(ubyte[T.sizeof]*) &source;
+                } ();
             }
             else
             {
-                import core.stdc.string : memcpy;
-                () @trusted { memcpy(&source, __traits(initSymbol, T).ptr, sz); }();
+                for (size_t i = 0; i < source.length; ++i)
+                    moveEmplaceImpl(target[i], source[i]);
             }
         }
     }
-    else static if (__traits(isStaticArray, T))
-    {
-        for (size_t i = 0; i < source.length; ++i)
-            moveEmplaceImpl(target[i], source[i]);
-    }
     else
     {
         // Primitive data (including pointers and arrays) or class -
@@ -2258,6 +2325,13 @@ pure nothrow @nogc @system unittest
     f(move(ncarray));
 }
 
+//debug = PRINTF;
+
+debug(PRINTF)
+{
+    import core.stdc.stdio;
+}
+
 /// Implementation of `_d_delstruct` and `_d_delstructTrace`
 template _d_delstructImpl(T)
 {
@@ -2361,3 +2435,270 @@ template _d_delstructImpl(T)
     assert(innerDtors == 2);
     assert(outerDtors == 1);
 }
+
+// issue 25552
+pure nothrow @system unittest
+{
+    int i;
+    struct Nested
+    {
+    pure nothrow @nogc:
+        char[1] arr; // char.init is not 0
+        ~this() { ++i; }
+    }
+
+    {
+        Nested[1] dst = void;
+        Nested[1] src = [Nested(['a'])];
+
+        moveEmplace(src, dst);
+        assert(i == 0);
+        assert(dst[0].arr == ['a']);
+        assert(src[0].arr == [char.init]);
+        assert(dst[0].tupleof[$-1] is src[0].tupleof[$-1]);
+    }
+    assert(i == 2);
+}
+
+// issue 25552
+@safe unittest
+{
+    int i;
+    struct Nested
+    {
+        ~this() { ++i; }
+    }
+
+    static struct NotNested
+    {
+        Nested n;
+    }
+
+    static struct Deep
+    {
+        NotNested nn;
+    }
+
+    static struct Deeper
+    {
+        NotNested[1] nn;
+    }
+
+    static assert(__traits(isZeroInit, Nested));
+    static assert(__traits(isZeroInit, NotNested));
+    static assert(__traits(isZeroInit, Deep));
+    static assert(__traits(isZeroInit, Deeper));
+
+    {
+        auto a = NotNested(Nested());
+        assert(a.n.tupleof[$-1]);
+        auto b = move(a);
+        assert(b.n.tupleof[$-1]);
+        assert(a.n.tupleof[$-1] is b.n.tupleof[$-1]);
+
+        auto c = Deep(NotNested(Nested()));
+        auto d = move(c);
+        assert(d.nn.n.tupleof[$-1]);
+        assert(c.nn.n.tupleof[$-1] is d.nn.n.tupleof[$-1]);
+
+        auto e = Deeper([NotNested(Nested())]);
+        auto f = move(e);
+        assert(f.nn[0].n.tupleof[$-1]);
+        assert(e.nn[0].n.tupleof[$-1] is f.nn[0].n.tupleof[$-1]);
+    }
+    assert(i == 6);
+}
+
+// issue 25552
+@safe unittest
+{
+    int i;
+    struct Nested
+    {
+        align(32) // better still find context pointer correctly!
+        int[3] stuff = [0, 1, 2];
+        ~this() { ++i; }
+    }
+
+    static struct NoAssign
+    {
+        int value;
+        @disable void opAssign(typeof(this));
+    }
+
+    static struct NotNested
+    {
+        int before = 42;
+        align(Nested.alignof * 4) // better still find context pointer correctly!
+        Nested n;
+        auto after = NoAssign(43);
+    }
+
+    static struct Deep
+    {
+        NotNested nn;
+    }
+
+    static struct Deeper
+    {
+        NotNested[1] nn;
+    }
+
+    static assert(!__traits(isZeroInit, Nested));
+    static assert(!__traits(isZeroInit, NotNested));
+    static assert(!__traits(isZeroInit, Deep));
+    static assert(!__traits(isZeroInit, Deeper));
+
+    {
+        auto a = NotNested(1, Nested([3, 4, 5]), NoAssign(2));
+        auto b = move(a);
+        assert(b.n.tupleof[$-1]);
+        assert(a.n.tupleof[$-1] is b.n.tupleof[$-1]);
+        assert(a.n.stuff == [0, 1, 2]);
+        assert(a.before == 42);
+        assert(a.after == NoAssign(43));
+
+        auto c = Deep(NotNested(1, Nested([3, 4, 5]), NoAssign(2)));
+        auto d = move(c);
+        assert(d.nn.n.tupleof[$-1]);
+        assert(c.nn.n.tupleof[$-1] is d.nn.n.tupleof[$-1]);
+        assert(c.nn.n.stuff == [0, 1, 2]);
+        assert(c.nn.before == 42);
+        assert(c.nn.after == NoAssign(43));
+
+        auto e = Deeper([NotNested(1, Nested([3, 4, 5]), NoAssign(2))]);
+        auto f = move(e);
+        assert(f.nn[0].n.tupleof[$-1]);
+        assert(e.nn[0].n.tupleof[$-1] is f.nn[0].n.tupleof[$-1]);
+        assert(e.nn[0].n.stuff == [0, 1, 2]);
+        assert(e.nn[0].before == 42);
+        assert(e.nn[0].after == NoAssign(43));
+    }
+    assert(i == 6);
+}
+
+// wipes source after moving
+pragma(inline, true)
+private void wipe(T, Init...)(return scope ref T source, ref const scope Init initializer) @trusted
+if (!Init.length ||
+    ((Init.length == 1) && (is(immutable T == immutable Init[0]))))
+{
+    static if (__traits(isStaticArray, T) && hasContextPointers!T)
+    {
+        for (auto i = 0; i < T.length; i++)
+            static if (Init.length)
+                wipe(source[i], initializer[0][i]);
+            else
+                wipe(source[i]);
+    }
+    else static if (is(T == struct) && hasContextPointers!T)
+    {
+        import core.internal.traits : anySatisfy;
+        static if (anySatisfy!(hasContextPointers, typeof(T.tupleof)))
+        {
+            static foreach (i; 0 .. T.tupleof.length - __traits(isNested, T))
+                static if (Init.length)
+                    wipe(source.tupleof[i], initializer[0].tupleof[i]);
+                else
+                    wipe(source.tupleof[i]);
+        }
+        else
+        {
+            static if (__traits(isNested, T))
+                enum sz = T.tupleof[$-1].offsetof;
+            else
+                enum sz = T.sizeof;
+
+            static if (Init.length)
+                *cast(ubyte[sz]*) &source = *cast(ubyte[sz]*) &initializer[0];
+            else
+                *cast(ubyte[sz]*) &source = 0;
+        }
+    }
+    else
+    {
+        import core.internal.traits : hasElaborateAssign, isAssignable;
+        static if (Init.length)
+        {
+            static if (hasElaborateAssign!T || !isAssignable!T)
+                *cast(ubyte[T.sizeof]*) &source = *cast(ubyte[T.sizeof]*) &initializer[0];
+            else
+                source = *cast(T*) &initializer[0];
+        }
+        else
+        {
+            *cast(ubyte[T.sizeof]*) &source = 0;
+        }
+    }
+}
+
+/**
+ * Allocate an exception of type `T` from the exception pool and call its constructor.
+ * It has the same interface as `rt.lifetime._d_newclass()`.
+ * `T` must be Throwable or derived from it, must declare an explicit ctor
+ * and cannot be a COM or C++ class.
+ * Returns:
+ *      constructed instance of the type
+ */
+T _d_newThrowable(T, Args...)(auto ref Args args) @trusted
+    if (is(T : Throwable) && is(typeof(T.__ctor(forward!args))) &&
+        __traits(getLinkage, T) == "D")
+{
+    debug(PRINTF) printf("_d_newThrowable(%s)\n", cast(char*) T.stringof);
+
+    import core.stdc.stdlib : malloc;
+    auto init = __traits(initSymbol, T);
+    void* p = malloc(init.length);
+    if (!p)
+    {
+        import core.exception : onOutOfMemoryError;
+        onOutOfMemoryError();
+    }
+
+    debug(PRINTF) printf(" p = %p\n", p);
+
+    // initialize it
+    p[0 .. init.length] = init[];
+
+    import core.internal.traits : hasIndirections;
+    if (hasIndirections!T)
+    {
+        // Inform the GC about the pointers in the object instance
+        import core.memory : GC;
+        GC.addRange(p, init.length);
+    }
+
+    debug(PRINTF) printf("initialization done\n");
+
+    (cast(Throwable) p).refcount() = 1;
+
+    auto t = cast(T) p;
+    t.__ctor(forward!args);
+
+    return t;
+}
+
+@system unittest
+{
+    class E : Exception
+    {
+        int x;
+
+        this(int x, string msg = "", Throwable nextInChain = null)
+        {
+            super(msg, nextInChain);
+            this.x = x;
+        }
+    }
+
+    auto exc = _d_newThrowable!Exception("Exception");
+    assert(exc.refcount() == 1);
+    assert(exc.msg == "Exception");
+
+    static assert(!__traits(compiles, _d_newThrowable!E()));
+
+    auto e = _d_newThrowable!E(42, "E", null);
+    assert(e.refcount() == 1);
+    assert(e.x == 42);
+    assert(e.msg == "E");
+}
diff --git a/libphobos/libdruntime/core/memory.d b/libphobos/libdruntime/core/memory.d
index c4df0f2d0dd..6ba569a241c 100644
--- a/libphobos/libdruntime/core/memory.d
+++ b/libphobos/libdruntime/core/memory.d
@@ -459,8 +459,11 @@ extern(C):
      * Throws:
      *  OutOfMemoryError on allocation failure.
      */
-    pragma(mangle, "gc_malloc") static void* malloc(size_t sz, uint ba = 0, const scope TypeInfo ti = null) pure nothrow;
-
+    version (D_ProfileGC)
+        pragma(mangle, "gc_mallocTrace") static void* malloc(size_t sz, uint ba = 0, const scope TypeInfo ti = null,
+            string file = __FILE__, int line = __LINE__, string func = __FUNCTION__) pure nothrow;
+    else
+        pragma(mangle, "gc_malloc") static void* malloc(size_t sz, uint ba = 0, const scope TypeInfo ti = null) pure nothrow;
 
     /**
      * Requests an aligned block of managed memory from the garbage collector.
@@ -482,7 +485,11 @@ extern(C):
      * Throws:
      *  OutOfMemoryError on allocation failure.
      */
-    pragma(mangle, "gc_qalloc") static BlkInfo qalloc(size_t sz, uint ba = 0, const scope TypeInfo ti = null) pure nothrow;
+    version (D_ProfileGC)
+        pragma(mangle, "gc_qallocTrace") static BlkInfo qalloc(size_t sz, uint ba = 0, const scope TypeInfo ti = null,
+            string file = __FILE__, int line = __LINE__, string func = __FUNCTION__) pure nothrow;
+    else
+        pragma(mangle, "gc_qalloc") static BlkInfo qalloc(size_t sz, uint ba = 0, const scope TypeInfo ti = null) pure nothrow;
 
 
     /**
@@ -506,7 +513,11 @@ extern(C):
      * Throws:
      *  OutOfMemoryError on allocation failure.
      */
-    pragma(mangle, "gc_calloc") static void* calloc(size_t sz, uint ba = 0, const TypeInfo ti = null) pure nothrow;
+    version (D_ProfileGC)
+        pragma(mangle, "gc_callocTrace") static void* calloc(size_t sz, uint ba = 0, const TypeInfo ti = null,
+            string file = __FILE__, int line = __LINE__, string func = __FUNCTION__) pure nothrow;
+    else
+        pragma(mangle, "gc_calloc") static void* calloc(size_t sz, uint ba = 0, const TypeInfo ti = null) pure nothrow;
 
 
     /**
@@ -551,7 +562,11 @@ extern(C):
      * Throws:
      *  `OutOfMemoryError` on allocation failure.
      */
-    pragma(mangle, "gc_realloc") static void* realloc(return scope void* p, size_t sz, uint ba = 0, const TypeInfo ti = null) pure nothrow;
+    version (D_ProfileGC)
+        pragma(mangle, "gc_reallocTrace") static void* realloc(return scope void* p, size_t sz, uint ba = 0, const TypeInfo ti = null,
+            string file = __FILE__, int line = __LINE__, string func = __FUNCTION__) pure nothrow;
+    else
+        pragma(mangle, "gc_realloc") static void* realloc(return scope void* p, size_t sz, uint ba = 0, const TypeInfo ti = null) pure nothrow;
 
     // https://issues.dlang.org/show_bug.cgi?id=13111
     ///
@@ -593,7 +608,12 @@ extern(C):
      *  as an indicator of success. $(LREF capacity) should be used to
      *  retrieve actual usable slice capacity.
      */
-    pragma(mangle, "gc_extend") static size_t extend(void* p, size_t mx, size_t sz, const TypeInfo ti = null) pure nothrow;
+    version (D_ProfileGC)
+        pragma(mangle, "gc_extendTrace") static size_t extend(void* p, size_t mx, size_t sz, const TypeInfo ti = null,
+            string file = __FILE__, int line = __LINE__, string func = __FUNCTION__) pure nothrow;
+    else
+        pragma(mangle, "gc_extend") static size_t extend(void* p, size_t mx, size_t sz, const TypeInfo ti = null) pure nothrow;
+
     /// Standard extending
     unittest
     {
diff --git a/libphobos/libdruntime/core/stdc/math.d b/libphobos/libdruntime/core/stdc/math.d
index de029c41af8..0c5da0bfefa 100644
--- a/libphobos/libdruntime/core/stdc/math.d
+++ b/libphobos/libdruntime/core/stdc/math.d
@@ -850,59 +850,59 @@ else version (CRuntime_UClibc)
         FP_FAST_FMAL = 0,
     }
 
-    int __fpclassifyf(float x);
-    int __fpclassify(double x);
-    int __fpclassifyl(real x);
+    pure int __fpclassifyf(float x);
+    pure int __fpclassify(double x);
+    pure int __fpclassifyl(real x);
 
-    int __finitef(float x);
-    int __finite(double x);
-    int __finitel(real x);
+    pure int __finitef(float x);
+    pure int __finite(double x);
+    pure int __finitel(real x);
 
-    int __isinff(float x);
-    int __isinf(double x);
-    int __isinfl(real x);
+    pure int __isinff(float x);
+    pure int __isinf(double x);
+    pure int __isinfl(real x);
 
-    int __isnanf(float x);
-    int __isnan(double x);
-    int __isnanl(real x);
+    pure int __isnanf(float x);
+    pure int __isnan(double x);
+    pure int __isnanl(real x);
 
-    int __signbitf(float x);
-    int __signbit(double x);
-    int __signbitl(real x);
+    pure int __signbitf(float x);
+    pure int __signbit(double x);
+    pure int __signbitl(real x);
 
     ///
-    pragma(mangle, "__fpclassifyf") int fpclassify(float x);
+    pragma(mangle, "__fpclassifyf") pure int fpclassify(float x);
     ///
-    pragma(mangle, "__fpclassify")  int fpclassify(double x);
+    pragma(mangle, "__fpclassify")  pure int fpclassify(double x);
     ///
     pragma(mangle, real.sizeof == double.sizeof ? "__fpclassify" : "__fpclassifyl")
-    int fpclassify(real x);
+    pure int fpclassify(real x);
 
     ///
-    pragma(mangle, "__finitef") int isfinite(float x);
+    pragma(mangle, "__finitef") pure int isfinite(float x);
     ///
-    pragma(mangle, "__finite")  int isfinite(double x);
+    pragma(mangle, "__finite")  pure int isfinite(double x);
     ///
     pragma(mangle, real.sizeof == double.sizeof ? "__finite" : "__finitel")
-    int isfinite(real x);
+    pure int isfinite(real x);
 
     ///
-    pragma(mangle, "__isinff") int isinf(float x);
+    pragma(mangle, "__isinff") pure int isinf(float x);
     ///
-    pragma(mangle, "__isinf")  int isinf(double x);
+    pragma(mangle, "__isinf")  pure int isinf(double x);
     ///
     pragma(mangle, real.sizeof == double.sizeof ? "__isinf" : "__isinfl")
-    int isinf(real x);
+    pure int isinf(real x);
 
     ///
-    pragma(mangle, "__isnanf") int isnan(float x);
+    pragma(mangle, "__isnanf") pure int isnan(float x);
     ///
-    pragma(mangle, "__isnan")  int isnan(double x);
+    pragma(mangle, "__isnan")  pure int isnan(double x);
     ///
     pragma(mangle, real.sizeof == double.sizeof ? "__isnan" : "__isnanl")
-    int isnan(real x);
+    pure int isnan(real x);
 
-  extern (D)
+  extern (D) pure
   {
     ///
     int isnormal(float x)       { return fpclassify(x) == FP_NORMAL; }
@@ -913,12 +913,12 @@ else version (CRuntime_UClibc)
   }
 
     ///
-    pragma(mangle, "__signbitf") int signbit(float x);
+    pragma(mangle, "__signbitf") pure int signbit(float x);
     ///
-    pragma(mangle, "__signbit")  int signbit(double x);
+    pragma(mangle, "__signbit")  pure int signbit(double x);
     ///
     pragma(mangle, real.sizeof == double.sizeof ? "__signbit" : "__signbitl")
-    int signbit(real x);
+    pure int signbit(real x);
 }
 else version (Darwin)
 {
@@ -3089,7 +3089,7 @@ else version (OpenBSD)
     ///
     pure real atanl(real x);
     ///
-    real atan2l(real x, real y);
+    real atan2l(real y, real x);
     ///
     pure real cosl(real x);
     ///
@@ -3377,7 +3377,7 @@ else version (DragonFlyBSD)
     pure real acosl(real x);
     pure real asinl(real x);
     pure real atanl(real x);
-    real atan2l(real x, real y);
+    real atan2l(real y, real x);
     pure real cosl(real x);
     pure real sinl(real x);
     pure real tanl(real x);
@@ -3872,7 +3872,7 @@ else version (CRuntime_UClibc)
     ///
     float   atan2f(float y, float x);
     ///
-    extern(D) real atan2l(real y, real x) { return atan2(cast(double) x, cast(double) y); }
+    extern(D) real atan2l(real y, real x) { return atan2(cast(double) y, cast(double) x); }
 
     ///
     pure double  cos(double x);
diff --git a/libphobos/libdruntime/core/sys/darwin/dlfcn.d b/libphobos/libdruntime/core/sys/darwin/dlfcn.d
index 406d588abf3..6084f3f01f1 100644
--- a/libphobos/libdruntime/core/sys/darwin/dlfcn.d
+++ b/libphobos/libdruntime/core/sys/darwin/dlfcn.d
@@ -25,20 +25,6 @@ nothrow:
 
 public import core.sys.posix.dlfcn;
 
-struct Dl_info
-{
-    const(char)* dli_fname;
-    void*        dli_fbase;
-    const(char)* dli_sname;
-    void*        dli_saddr;
-}
-
-int dladdr(const scope void* addr, Dl_info* info);
-
-enum RTLD_NOLOAD = 0x10;
-enum RTLD_NODELETE = 0x80;
-enum RTLD_FIRST = 0x100;
-
 enum RTLD_NEXT = cast(void*) -1;
 enum RTLD_DEFAULT = cast(void*) -2;
 enum RTLD_SELF = cast(void*) -3;
diff --git a/libphobos/libdruntime/core/sys/dragonflybsd/dlfcn.d b/libphobos/libdruntime/core/sys/dragonflybsd/dlfcn.d
index 2c5d8d79c22..0e8b15ccf88 100644
--- a/libphobos/libdruntime/core/sys/dragonflybsd/dlfcn.d
+++ b/libphobos/libdruntime/core/sys/dragonflybsd/dlfcn.d
@@ -14,18 +14,6 @@ public import core.sys.posix.dlfcn;
 
 extern (C) nothrow @nogc @system:
 
-/*
- * Modes and flags for dlopen().
- */
-static assert(RTLD_LAZY   == 1);
-static assert(RTLD_NOW    == 2);
-enum RTLD_MODEMASK        =  0x3;
-static assert(RTLD_GLOBAL == 0x100);
-static assert(RTLD_LOCAL  == 0);
-enum RTLD_TRACE           =  0x200;
-enum RTLD_NODELETE        =  0x01000;
-enum RTLD_NOLOAD          =  0x02000;
-
 /*
  * Request arguments for dlinfo().
  */
@@ -42,17 +30,6 @@ enum RTLD_NEXT    = cast(void *)-1;    /* Search subsequent objects. */
 enum RTLD_DEFAULT = cast(void *)-2;    /* Use default search algorithm. */
 enum RTLD_SELF    = cast(void *)-3;    /* Search the caller itself. */
 
-/*
- * Structure filled in by dladdr().
- */
-struct Dl_info {
-    const(char)     *dli_fname;     /* Pathname of shared object. */
-    void            *dli_fbase;     /* Base address of shared object. */
-    const(char)     *dli_sname;     /* Name of nearest symbol. */
-    void            *dli_saddr;     /* Address of nearest symbol. */
-}
-
-
 /*
  * Structures, returned by the RTLD_DI_SERINFO dlinfo() request.
  */
@@ -91,7 +68,6 @@ extern(C) {
 }
 
 void*    fdlopen(int, int);
-int      dladdr(const(void)*, Dl_info*);
 dlfunc_t dlfunc(void*, const(char)*);
 int      dlinfo(void*, int, void*);
 /*void     dllockinit(void* _context,
diff --git a/libphobos/libdruntime/core/sys/freebsd/dlfcn.d b/libphobos/libdruntime/core/sys/freebsd/dlfcn.d
index 7baacfeeb7b..aac41d8e7d6 100644
--- a/libphobos/libdruntime/core/sys/freebsd/dlfcn.d
+++ b/libphobos/libdruntime/core/sys/freebsd/dlfcn.d
@@ -16,18 +16,6 @@ nothrow:
 
 enum __BSD_VISIBLE = true;
 
-/*
- * Modes and flags for dlopen().
- */
-static assert(RTLD_LAZY   == 1);
-static assert(RTLD_NOW    == 2);
-enum RTLD_MODEMASK        =  0x3;
-static assert(RTLD_GLOBAL == 0x100);
-static assert(RTLD_LOCAL  == 0);
-enum RTLD_TRACE           =  0x200;
-enum RTLD_NODELETE        =  0x01000;
-enum RTLD_NOLOAD          =  0x02000;
-
 /*
  * Request arguments for dlinfo().
  */
@@ -46,16 +34,6 @@ enum RTLD_SELF    = cast(void *)-3;    /* Search the caller itself. */
 
 static if (__BSD_VISIBLE)
 {
-    /*
-     * Structure filled in by dladdr().
-     */
-    struct Dl_info {
-        const(char)     *dli_fname;     /* Pathname of shared object. */
-        void            *dli_fbase;     /* Base address of shared object. */
-        const(char)     *dli_sname;     /* Name of nearest symbol. */
-        void            *dli_saddr;     /* Address of nearest symbol. */
-    }
-
     /*-
      * The actual type declared by this typedef is immaterial, provided that
      * it is a function pointer.  Its purpose is to provide a return type for
@@ -97,7 +75,6 @@ extern(C) {
 static if (__BSD_VISIBLE)
 {
     void*    fdlopen(int, int);
-    int      dladdr(const(void)*, Dl_info*);
     dlfunc_t dlfunc(void*, const(char)*);
     int      dlinfo(void*, int, void*);
     void     dllockinit(void* _context,
diff --git a/libphobos/libdruntime/core/sys/linux/dlfcn.d b/libphobos/libdruntime/core/sys/linux/dlfcn.d
index a815d0907fe..4a122849471 100644
--- a/libphobos/libdruntime/core/sys/linux/dlfcn.d
+++ b/libphobos/libdruntime/core/sys/linux/dlfcn.d
@@ -34,16 +34,6 @@ import core.sys.linux.config;
 version (X86_Any)
 {
     // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
-    // enum RTLD_LAZY = 0x00001; // POSIX
-    // enum RTLD_NOW = 0x00002; // POSIX
-    enum RTLD_BINDING_MASK = 0x3;
-    enum RTLD_NOLOAD = 0x00004;
-    enum RTLD_DEEPBIND = 0x00008;
-
-    // enum RTLD_GLOBAL = 0x00100; // POSIX
-    // enum RTLD_LOCAL = 0; // POSIX
-    enum RTLD_NODELETE = 0x01000;
-
     static if (__USE_GNU)
     {
         RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
@@ -58,16 +48,6 @@ version (X86_Any)
 else version (HPPA_Any)
 {
     // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/hppa/bits/dlfcn.h
-    // enum RTLD_LAZY = 0x0001; // POSIX
-    // enum RTLD_NOW = 0x0002; // POSIX
-    enum RTLD_BINDING_MASK = 0x3;
-    enum RTLD_NOLOAD = 0x00004;
-    enum RTLD_DEEPBIND = 0x00008;
-
-    // enum RTLD_GLOBAL = 0x0004; // POSIX
-    // enum RTLD_LOCAL = 0; // POSIX
-    enum RTLD_NODELETE = 0x01000;
-
     static if (__USE_GNU)
     {
         RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
@@ -82,16 +62,6 @@ else version (HPPA_Any)
 else version (MIPS_Any)
 {
     // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/mips/bits/dlfcn.h
-    // enum RTLD_LAZY = 0x0001; // POSIX
-    // enum RTLD_NOW = 0x0002; // POSIX
-    enum RTLD_BINDING_MASK = 0x3;
-    enum RTLD_NOLOAD = 0x00008;
-    enum RTLD_DEEPBIND = 0x00010;
-
-    // enum RTLD_GLOBAL = 0x0004; // POSIX
-    // enum RTLD_LOCAL = 0; // POSIX
-    enum RTLD_NODELETE = 0x01000;
-
     static if (__USE_GNU)
     {
         RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
@@ -106,16 +76,6 @@ else version (MIPS_Any)
 else version (PPC_Any)
 {
     // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
-    // enum RTLD_LAZY = 0x0001; // POSIX
-    // enum RTLD_NOW = 0x0002; // POSIX
-    enum RTLD_BINDING_MASK = 0x3;
-    enum RTLD_NOLOAD = 0x00004;
-    enum RTLD_DEEPBIND = 0x00008;
-
-    // enum RTLD_GLOBAL = 0x00100; // POSIX
-    // enum RTLD_LOCAL = 0; // POSIX
-    enum RTLD_NODELETE = 0x01000;
-
     static if (__USE_GNU)
     {
         RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
@@ -130,16 +90,6 @@ else version (PPC_Any)
 else version (ARM_Any)
 {
     // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
-    // enum RTLD_LAZY = 0x0001; // POSIX
-    // enum RTLD_NOW = 0x0002; // POSIX
-    enum RTLD_BINDING_MASK = 0x3;
-    enum RTLD_NOLOAD = 0x00004;
-    enum RTLD_DEEPBIND = 0x00008;
-
-    // enum RTLD_GLOBAL = 0x00100; // POSIX
-    // enum RTLD_LOCAL = 0; // POSIX
-    enum RTLD_NODELETE = 0x01000;
-
     static if (__USE_GNU)
     {
         RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
@@ -154,16 +104,6 @@ else version (ARM_Any)
 else version (RISCV_Any)
 {
     // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
-    // enum RTLD_LAZY = 0x0001; // POSIX
-    // enum RTLD_NOW = 0x0002; // POSIX
-    enum RTLD_BINDING_MASK = 0x3;
-    enum RTLD_NOLOAD = 0x00004;
-    enum RTLD_DEEPBIND = 0x00008;
-
-    // enum RTLD_GLOBAL = 0x00100; // POSIX
-    // enum RTLD_LOCAL = 0; // POSIX
-    enum RTLD_NODELETE = 0x01000;
-
     static if (__USE_GNU)
     {
         RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
@@ -178,16 +118,6 @@ else version (RISCV_Any)
 else version (SPARC_Any)
 {
     // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
-    // enum RTLD_LAZY = 0x0001; // POSIX
-    // enum RTLD_NOW = 0x0002; // POSIX
-    enum RTLD_BINDING_MASK = 0x3;
-    enum RTLD_NOLOAD = 0x00004;
-    enum RTLD_DEEPBIND = 0x00008;
-
-    // enum RTLD_GLOBAL = 0x00100; // POSIX
-    // enum RTLD_LOCAL = 0; // POSIX
-    enum RTLD_NODELETE = 0x01000;
-
     static if (__USE_GNU)
     {
         RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
@@ -202,16 +132,6 @@ else version (SPARC_Any)
 else version (IBMZ_Any)
 {
     // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
-    // enum RTLD_LAZY = 0x0001; // POSIX
-    // enum RTLD_NOW = 0x0002; // POSIX
-    enum RTLD_BINDING_MASK = 0x3;
-    enum RTLD_NOLOAD = 0x00004;
-    enum RTLD_DEEPBIND = 0x00008;
-
-    // enum RTLD_GLOBAL = 0x00100; // POSIX
-    // enum RTLD_LOCAL = 0; // POSIX
-    enum RTLD_NODELETE = 0x01000;
-
     static if (__USE_GNU)
     {
         RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
@@ -251,15 +171,6 @@ static if (__USE_GNU)
 
 static if (__USE_GNU)
 {
-    struct Dl_info
-    {
-        const(char)* dli_fname;
-        void* dli_fbase;
-        const(char)* dli_sname;
-        void* dli_saddr;
-    }
-
-    int dladdr(const scope void* __address, Dl_info* __info);
     int dladdr1(void* __address, Dl_info* __info, void** __extra_info, int __flags);
 
     enum
diff --git a/libphobos/libdruntime/core/sys/linux/sys/inotify.d b/libphobos/libdruntime/core/sys/linux/sys/inotify.d
index e0acf33fa51..11bdc85cf78 100644
--- a/libphobos/libdruntime/core/sys/linux/sys/inotify.d
+++ b/libphobos/libdruntime/core/sys/linux/sys/inotify.d
@@ -6,7 +6,21 @@
  */
 module core.sys.linux.sys.inotify;
 
-version (linux):
+// The BSDs (including macOS) have a kqueue-backed API-compatible inotify
+// library in ports. However, inotify is a Linux interface so it lives here.
+// All BSD people need this library to use inotify:
+//   https://github.com/libinotify-kqueue/libinotify-kqueue
+// It is the responsibility of all BSD people to configure the library before
+// using this interface.
+
+version (linux)        version = LinuxOrCompatible;
+version (Darwin)       version = LinuxOrCompatible;
+version (FreeBSD)      version = LinuxOrCompatible;
+version (OpenBSD)      version = LinuxOrCompatible;
+version (NetBSD)       version = LinuxOrCompatible;
+version (DragonFlyBSD) version = LinuxOrCompatible;
+
+version (LinuxOrCompatible):
 extern (C):
 @system:
 nothrow:
diff --git a/libphobos/libdruntime/core/sys/netbsd/dlfcn.d b/libphobos/libdruntime/core/sys/netbsd/dlfcn.d
index 468ffbfe435..3785592fcd6 100644
--- a/libphobos/libdruntime/core/sys/netbsd/dlfcn.d
+++ b/libphobos/libdruntime/core/sys/netbsd/dlfcn.d
@@ -18,17 +18,6 @@ nothrow:
 
 enum __BSD_VISIBLE = true;
 
-/*
- * Modes and flags for dlopen().
- */
-static assert(RTLD_LAZY   == 1);
-static assert(RTLD_NOW    == 2);
-static assert(RTLD_GLOBAL == 0x100);
-static assert(RTLD_LOCAL  == 0x200);
-//enum RTLD_TRACE           =  0x200;
-enum RTLD_NODELETE        =  0x01000;
-enum RTLD_NOLOAD          =  0x02000;
-
 /*
  * Request arguments for dlinfo().
  */
@@ -47,16 +36,6 @@ enum RTLD_SELF    = cast(void *)-3;    /* Search the caller itself. */
 
 static if (__BSD_VISIBLE)
 {
-    /*
-     * Structure filled in by dladdr().
-     */
-    struct Dl_info {
-        const(char)     *dli_fname;     /* Pathname of shared object. */
-        void            *dli_fbase;     /* Base address of shared object. */
-        const(char)     *dli_sname;     /* Name of nearest symbol. */
-        void            *dli_saddr;     /* Address of nearest symbol. */
-    }
-
     /*-
      * The actual type declared by this typedef is immaterial, provided that
      * it is a function pointer.  Its purpose is to provide a return type for
@@ -97,16 +76,6 @@ extern(C) {
 
 static if (__BSD_VISIBLE)
 {
-    //void*    fdlopen(int, int);
-    int      dladdr(const(void)*, Dl_info*);
-    //dlfunc_t dlfunc(void*, const(char)*);
     int      dlinfo(void*, int, void*);
-    /+void     dllockinit(void* _context,
-        void* function(void* _context) _lock_create,
-        void  function(void* _lock)    _rlock_acquire,
-        void  function(void* _lock)    _wlock_acquire,
-        void  function(void* _lock)    _lock_release,
-        void  function(void* _lock)    _lock_destroy,
-        void  function(void* _context) _context_destroy);+/
     void*    dlvsym(void*, const(char)*, const(char)*);
 }
diff --git a/libphobos/libdruntime/core/sys/openbsd/dlfcn.d b/libphobos/libdruntime/core/sys/openbsd/dlfcn.d
index b28dc63d5c7..1227669e624 100644
--- a/libphobos/libdruntime/core/sys/openbsd/dlfcn.d
+++ b/libphobos/libdruntime/core/sys/openbsd/dlfcn.d
@@ -11,13 +11,6 @@ version (OpenBSD):
 extern (C):
 nothrow:
 
-static assert(RTLD_LAZY   == 1);
-static assert(RTLD_NOW    == 2);
-static assert(RTLD_GLOBAL == 0x100);
-static assert(RTLD_LOCAL  == 0);
-enum RTLD_TRACE           =  0x200;
-enum RTLD_NODELETE        =  0x400;
-
 enum RTLD_NEXT    = cast(void *)-1;
 enum RTLD_DEFAULT = cast(void *)-2;
 enum RTLD_SELF    = cast(void *)-3;
diff --git a/libphobos/libdruntime/core/sys/posix/dirent.d b/libphobos/libdruntime/core/sys/posix/dirent.d
index 8a2440e1fa4..bffbc5149a1 100644
--- a/libphobos/libdruntime/core/sys/posix/dirent.d
+++ b/libphobos/libdruntime/core/sys/posix/dirent.d
@@ -37,12 +37,124 @@ nothrow:
 // Required
 //
 /*
-DIR
-
 struct dirent
 {
     char[] d_name;
 }
+*/
+
+version (linux)
+{
+    struct dirent
+    {
+        ino_t       d_ino;
+        off_t       d_off;
+        ushort      d_reclen;
+        ubyte       d_type;
+        char[256]   d_name = 0;
+    }
+}
+else version (Darwin)
+{
+    // _DARWIN_FEATURE_64_BIT_INODE dirent is default for Mac OSX >10.5 and is
+    // only meaningful type for other OS X/Darwin variants (e.g. iOS).
+    // man dir(5) has some info, man stat(2) gives details.
+    struct dirent
+    {
+        ino_t       d_ino;
+        alias       d_fileno = d_ino;
+        ulong       d_seekoff;
+        ushort      d_reclen;
+        ushort      d_namlen;
+        ubyte       d_type;
+        char[1024]  d_name = 0;
+    }
+}
+else version (FreeBSD)
+{
+    import core.sys.freebsd.config;
+
+    static if (__FreeBSD_version >= 1200000)
+    {
+        struct dirent
+        {
+            ino_t     d_fileno;
+            off_t     d_off;
+            ushort    d_reclen;
+            ubyte     d_type;
+            ubyte     d_pad0;
+            ushort    d_namlen;
+            ushort    d_pad1;
+            char[256] d_name = 0;
+        }
+    }
+    else
+    {
+        align(4)
+        struct dirent
+        {
+            uint      d_fileno;
+            ushort    d_reclen;
+            ubyte     d_type;
+            ubyte     d_namlen;
+            char[256] d_name = 0;
+        }
+    }
+}
+else version (NetBSD)
+{
+    struct dirent
+    {
+        ulong      d_fileno;
+        ushort    d_reclen;
+        ushort    d_namlen;
+        ubyte     d_type;
+        char[512] d_name = 0;
+    }
+}
+else version (OpenBSD)
+{
+    align(4)
+    struct dirent
+    {
+        ino_t     d_fileno;
+        off_t     d_off;
+        ushort    d_reclen;
+        ubyte     d_type;
+        ubyte     d_namlen;
+        ubyte[4]  __d_padding;
+        char[256] d_name = 0;
+    }
+}
+else version (DragonFlyBSD)
+{
+    struct dirent
+    {
+        ino_t     d_fileno;       /* file number of entry */
+        ushort    d_reclen;       /* strlen(d_name) */
+        ubyte     d_type;         /* file type, see blow */
+        ubyte     d_unused1;      /* padding, reserved */
+        uint      d_unused2;      /* reserved */
+        char[256] d_name = 0;     /* name, NUL-terminated */
+    }
+}
+else version (Solaris)
+{
+    struct dirent
+    {
+        ino_t d_ino;
+        off_t d_off;
+        ushort d_reclen;
+        char[1] d_name = 0;
+    }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+/*
+DIR
 
 int     closedir(DIR*);
 DIR*    opendir(const scope char*);
@@ -67,15 +179,6 @@ version (CRuntime_Glibc)
         DT_WHT      = 14
     }
 
-    struct dirent
-    {
-        ino_t       d_ino;
-        off_t       d_off;
-        ushort      d_reclen;
-        ubyte       d_type;
-        char[256]   d_name = 0;
-    }
-
     struct DIR
     {
         // Managed by OS
@@ -106,20 +209,6 @@ else version (Darwin)
         DT_WHT      = 14
     }
 
-    // _DARWIN_FEATURE_64_BIT_INODE dirent is default for Mac OSX >10.5 and is
-    // only meaningful type for other OS X/Darwin variants (e.g. iOS).
-    // man dir(5) has some info, man stat(2) gives details.
-    struct dirent
-    {
-        ino_t       d_ino;
-        alias       d_fileno = d_ino;
-        ulong       d_seekoff;
-        ushort      d_reclen;
-        ushort      d_namlen;
-        ubyte       d_type;
-        char[1024]  d_name = 0;
-    }
-
     struct DIR
     {
         // Managed by OS
@@ -157,33 +246,6 @@ else version (FreeBSD)
         DT_WHT      = 14
     }
 
-    static if (__FreeBSD_version >= 1200000)
-    {
-        struct dirent
-        {
-            ino_t     d_fileno;
-            off_t     d_off;
-            ushort    d_reclen;
-            ubyte     d_type;
-            ubyte     d_pad0;
-            ushort    d_namlen;
-            ushort    d_pad1;
-            char[256] d_name = 0;
-        }
-    }
-    else
-    {
-        align(4)
-        struct dirent
-        {
-            uint      d_fileno;
-            ushort    d_reclen;
-            ubyte     d_type;
-            ubyte     d_namlen;
-            char[256] d_name = 0;
-        }
-    }
-
     alias void* DIR;
 
     version (GNU)
@@ -213,15 +275,6 @@ else version (NetBSD)
         DT_WHT      = 14
     }
 
-    struct dirent
-    {
-        ulong      d_fileno;
-        ushort    d_reclen;
-        ushort    d_namlen;
-        ubyte     d_type;
-        char[512] d_name = 0;
-    }
-
     alias void* DIR;
 
     dirent* __readdir30(DIR*);
@@ -241,18 +294,6 @@ else version (OpenBSD)
         DT_SOCK     = 12,
     }
 
-    align(4)
-    struct dirent
-    {
-        ino_t     d_fileno;
-        off_t     d_off;
-        ushort    d_reclen;
-        ubyte     d_type;
-        ubyte     d_namlen;
-        ubyte[4]  __d_padding;
-        char[256] d_name = 0;
-    }
-
     alias void* DIR;
 
     dirent* readdir(DIR*);
@@ -273,30 +314,12 @@ else version (DragonFlyBSD)
         DT_DBF      = 15,         /* database record file */
     }
 
-    struct dirent
-    {
-        ino_t     d_fileno;       /* file number of entry */
-        ushort    d_reclen;       /* strlen(d_name) */
-        ubyte     d_type;         /* file type, see blow */
-        ubyte     d_unused1;      /* padding, reserved */
-        uint      d_unused2;      /* reserved */
-        char[256] d_name = 0;     /* name, NUL-terminated */
-    }
-
     alias void* DIR;
 
     dirent* readdir(DIR*);
 }
 else version (Solaris)
 {
-    struct dirent
-    {
-        ino_t d_ino;
-        off_t d_off;
-        ushort d_reclen;
-        char[1] d_name = 0;
-    }
-
     struct DIR
     {
         int dd_fd;
@@ -338,15 +361,6 @@ else version (CRuntime_Bionic)
         DT_WHT      = 14
     }
 
-    struct dirent
-    {
-        ulong       d_ino;
-        long        d_off;
-        ushort      d_reclen;
-        ubyte       d_type;
-        char[256]   d_name = 0;
-    }
-
     struct DIR
     {
     }
@@ -368,15 +382,6 @@ else version (CRuntime_Musl)
         DT_WHT      = 14
     }
 
-    struct dirent
-    {
-        ino_t       d_ino;
-        off_t       d_off;
-        ushort      d_reclen;
-        ubyte       d_type;
-        char[256]   d_name = 0;
-    }
-
     struct DIR
     {
     }
@@ -408,23 +413,6 @@ else version (CRuntime_UClibc)
         DT_WHT      = 14
     }
 
-    struct dirent
-    {
-        static if (__USE_FILE_OFFSET64)
-        {
-            ino64_t d_ino;
-            off64_t d_off;
-        }
-        else
-        {
-            ino_t d_ino;
-            off_t d_off;
-        }
-        ushort      d_reclen;
-        ubyte       d_type;
-        char[256]   d_name = 0;
-    }
-
     struct DIR
     {
         // Managed by OS
diff --git a/libphobos/libdruntime/core/sys/posix/dlfcn.d b/libphobos/libdruntime/core/sys/posix/dlfcn.d
index f6476ec3106..a9519ca234a 100644
--- a/libphobos/libdruntime/core/sys/posix/dlfcn.d
+++ b/libphobos/libdruntime/core/sys/posix/dlfcn.d
@@ -66,59 +66,100 @@ version (CRuntime_Glibc)
 {
     version (X86_Any)
     {
+        // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
         enum RTLD_LAZY      = 0x00001;
         enum RTLD_NOW       = 0x00002;
+        enum RTLD_BINDING_MASK = 0x3;
+        enum RTLD_NOLOAD    = 0x00004;
+        enum RTLD_DEEPBIND  = 0x00008;
         enum RTLD_GLOBAL    = 0x00100;
         enum RTLD_LOCAL     = 0x00000;
+        enum RTLD_NODELETE  = 0x01000;
     }
     else version (HPPA_Any)
     {
+        // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/hppa/bits/dlfcn.h
         enum RTLD_LAZY      = 0x0001;
         enum RTLD_NOW       = 0x0002;
+        enum RTLD_BINDING_MASK = 0x3;
+        enum RTLD_NOLOAD    = 0x00004;
+        enum RTLD_DEEPBIND  = 0x00008;
         enum RTLD_GLOBAL    = 0x0100;
         enum RTLD_LOCAL     = 0;
+        enum RTLD_NODELETE  = 0x01000;
     }
     else version (MIPS_Any)
     {
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/mips/bits/dlfcn.h
         enum RTLD_LAZY      = 0x0001;
         enum RTLD_NOW       = 0x0002;
+        enum RTLD_BINDING_MASK = 0x3;
+        enum RTLD_NOLOAD    = 0x00008;
+        enum RTLD_DEEPBIND  = 0x00010;
         enum RTLD_GLOBAL    = 0x0004;
         enum RTLD_LOCAL     = 0;
+        enum RTLD_NODELETE  = 0x01000;
     }
     else version (PPC_Any)
     {
+        // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
         enum RTLD_LAZY      = 0x00001;
         enum RTLD_NOW       = 0x00002;
+        enum RTLD_BINDING_MASK = 0x3;
+        enum RTLD_NOLOAD    = 0x00004;
+        enum RTLD_DEEPBIND  = 0x00008;
         enum RTLD_GLOBAL    = 0x00100;
         enum RTLD_LOCAL     = 0;
+        enum RTLD_NODELETE  = 0x01000;
     }
     else version (ARM_Any)
     {
+        // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
         enum RTLD_LAZY      = 0x00001;
         enum RTLD_NOW       = 0x00002;
+        enum RTLD_BINDING_MASK = 0x3;
+        enum RTLD_NOLOAD    = 0x00004;
+        enum RTLD_DEEPBIND  = 0x00008;
         enum RTLD_GLOBAL    = 0x00100;
         enum RTLD_LOCAL     = 0;
+        enum RTLD_NODELETE  = 0x01000;
     }
     else version (RISCV_Any)
     {
+        // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
         enum RTLD_LAZY      = 0x00001;
         enum RTLD_NOW       = 0x00002;
+        enum RTLD_BINDING_MASK = 0x3;
+        enum RTLD_NOLOAD    = 0x00004;
+        enum RTLD_DEEPBIND  = 0x00008;
         enum RTLD_GLOBAL    = 0x00100;
         enum RTLD_LOCAL     = 0;
+        enum RTLD_NODELETE  = 0x01000;
     }
     else version (SPARC_Any)
     {
+        // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
         enum RTLD_LAZY      = 0x00001;
         enum RTLD_NOW       = 0x00002;
+        enum RTLD_BINDING_MASK = 0x3;
+        enum RTLD_NOLOAD    = 0x00004;
+        enum RTLD_DEEPBIND  = 0x00008;
         enum RTLD_GLOBAL    = 0x00100;
         enum RTLD_LOCAL     = 0;
+        enum RTLD_NODELETE  = 0x01000;
+
     }
     else version (IBMZ_Any)
     {
+        // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
         enum RTLD_LAZY      = 0x00001;
         enum RTLD_NOW       = 0x00002;
+        enum RTLD_BINDING_MASK = 0x3;
+        enum RTLD_NOLOAD    = 0x00004;
+        enum RTLD_DEEPBIND  = 0x00008;
         enum RTLD_GLOBAL    = 0x00100;
         enum RTLD_LOCAL     = 0;
+        enum RTLD_NODELETE  = 0x01000;
     }
     else
         static assert(0, "unimplemented");
@@ -127,13 +168,25 @@ version (CRuntime_Glibc)
     char* dlerror();
     void* dlopen(const scope char*, int);
     void* dlsym(void*, const scope char*);
+    int dladdr(const scope void*, Dl_info*);
+
+    struct Dl_info
+    {
+        const(char)* dli_fname;
+        void* dli_fbase;
+        const(char)* dli_sname;
+        void* dli_saddr;
+    }
 }
 else version (Darwin)
 {
     enum RTLD_LAZY      = 0x00001;
     enum RTLD_NOW       = 0x00002;
+    enum RTLD_NOLOAD    = 0x10;
+    enum RTLD_NODELETE  = 0x80;
     enum RTLD_GLOBAL    = 0x00100;
     enum RTLD_LOCAL     = 0x00000;
+    enum RTLD_FIRST     = 0x100;
 
     int   dlclose(void*);
     char* dlerror();
@@ -153,8 +206,12 @@ else version (FreeBSD)
 {
     enum RTLD_LAZY      = 1;
     enum RTLD_NOW       = 2;
+    enum RTLD_MODEMASK  =  0x3;
     enum RTLD_GLOBAL    = 0x100;
     enum RTLD_LOCAL     = 0;
+    enum RTLD_TRACE     =  0x200;
+    enum RTLD_NODELETE  =  0x01000;
+    enum RTLD_NOLOAD    =  0x02000;
 
     int   dlclose(void*);
     char* dlerror();
@@ -199,6 +256,8 @@ else version (OpenBSD)
     enum RTLD_NOW       = 2;
     enum RTLD_GLOBAL    = 0x100;
     enum RTLD_LOCAL     = 0;
+    enum RTLD_TRACE     = 0x200;
+    enum RTLD_NODELETE  = 0x400;
 
     int   dlclose(void*);
     char* dlerror();
@@ -218,8 +277,12 @@ else version (DragonFlyBSD)
 {
     enum RTLD_LAZY      = 1;
     enum RTLD_NOW       = 2;
+    enum RTLD_MODEMASK  =  0x3;
     enum RTLD_GLOBAL    = 0x100;
     enum RTLD_LOCAL     = 0;
+    enum RTLD_TRACE     =  0x200;
+    enum RTLD_NODELETE  =  0x01000;
+    enum RTLD_NOLOAD    =  0x02000;
 
     int   dlclose(void*);
     char* dlerror();
@@ -239,8 +302,16 @@ else version (Solaris)
 {
     enum RTLD_LAZY      = 1;
     enum RTLD_NOW       = 2;
+    enum RTLD_NOLOAD    = 0x00004;
+    enum RTLD_DEEPBIND  = 0x00008;
     enum RTLD_GLOBAL    = 0x100;
     enum RTLD_LOCAL     = 0;
+    enum RTLD_PARENT    = 0x00200;
+    enum RTLD_GROUP     = 0x00400;
+    enum RTLD_WORLD     = 0x00800;
+    enum RTLD_NODELETE  = 0x01000;
+    enum RTLD_FIRST     = 0x02000;
+    enum RTLD_CONFGEN   = 0x10000;
 
     int   dlclose(void*);
     char* dlerror();
@@ -343,4 +414,13 @@ else version (CRuntime_UClibc)
     char* dlerror();
     void* dlopen(const scope char*, int);
     void* dlsym(void*, const scope char*);
+    int dladdr(const scope void*, Dl_info*);
+
+    struct Dl_info
+    {
+        const(char)* dli_fname;
+        void* dli_fbase;
+        const(char)* dli_sname;
+        void* dli_saddr;
+    }
 }
diff --git a/libphobos/libdruntime/core/sys/posix/fcntl.d b/libphobos/libdruntime/core/sys/posix/fcntl.d
index 6833f3badf0..3c196d29f22 100644
--- a/libphobos/libdruntime/core/sys/posix/fcntl.d
+++ b/libphobos/libdruntime/core/sys/posix/fcntl.d
@@ -96,12 +96,8 @@ struct flock
     off_t   l_len;
     pid_t   l_pid;
 }
-
-int creat(const scope char*, mode_t);
-int fcntl(int, int, ...);
-int open(const scope char*, int, ...);
 */
-version (CRuntime_Glibc)
+version (linux)
 {
     enum F_DUPFD        = 0;
     enum F_GETFD        = 1;
@@ -121,6 +117,12 @@ version (CRuntime_Glibc)
     enum F_SETLK        = 6;
     enum F_SETLKW       = 7;
   }
+  else version (PPC64)
+  {
+    enum F_GETLK        = 5;
+    enum F_SETLK        = 6;
+    enum F_SETLKW       = 7;
+  }
   else version (SystemZ)
   {
     static assert(off_t.sizeof == 8);
@@ -163,6 +165,19 @@ version (CRuntime_Glibc)
         enum O_SYNC         = 0x101000; // octal 04010000
         enum O_DSYNC        = 0x1000;   // octal   010000
         enum O_RSYNC        = O_SYNC;
+
+        enum O_DIRECTORY    = 0x010000; // octal   0200000
+        enum O_NOFOLLOW     = 0x020000; // octal   0400000
+        enum O_DIRECT       = 0x004000; // octal    040000
+        version (X86_64)
+            enum O_LARGEFILE = 0;
+        else
+            enum O_LARGEFILE = 0x08000; // octal   0100000
+        enum O_TMPFILE      = 0x410000; // octal 020200000
+        enum O_ASYNC        = 0x2000;   // octal    020000
+        enum O_NOATIME      = 0x40000;  // octal  01000000
+        enum O_PATH         = 0x200000; // octal 010000000
+        enum O_NDELAY       = O_NONBLOCK;
     }
     else version (HPPA_Any)
     {
@@ -177,6 +192,16 @@ version (CRuntime_Glibc)
         enum O_SYNC         = 0x48000;  // octal 01100000
         enum O_DSYNC        = 0x40000;  // octal 01000000
         enum O_RSYNC        = 0x80000;  // octal 02000000
+
+        enum O_DIRECTORY    = 0x001000; // octal 000010000
+        enum O_NOFOLLOW     = 0x000080; // octal 000000200
+        enum O_DIRECT       = 0x004000; // octal    040000
+        enum O_LARGEFILE    = 0x000800; // octal  00004000
+        enum O_TMPFILE      = 0x801000; // octal 040010000
+        enum O_ASYNC        = 0x2000;   // octal    020000
+        enum O_NOATIME      = 0x100000; // octal 004000000
+        enum O_PATH         = 0x400000; // octal 020000000
+        enum O_NDELAY       = O_NONBLOCK;
     }
     else version (MIPS_Any)
     {
@@ -191,6 +216,19 @@ version (CRuntime_Glibc)
         enum O_CLOEXEC      = 0x80000;
         enum O_RSYNC        = O_SYNC;
         enum O_SYNC         = 0x4010;
+
+        enum O_DIRECTORY    = 0x010000;
+        enum O_NOFOLLOW     = 0x020000;
+        enum O_DIRECT       = 0x8000;
+        version (MIPS_N64)
+            enum O_LARGEFILE = 0;
+        else
+            enum O_LARGEFILE = 0x2000;
+        enum O_TMPFILE      = 0x410000;
+        enum O_ASYNC        = 0x1000;
+        enum O_NOATIME      = 0x40000;
+        enum O_PATH         = 0x200000;
+        enum O_NDELAY       = O_NONBLOCK;
     }
     else version (PPC_Any)
     {
@@ -205,6 +243,19 @@ version (CRuntime_Glibc)
         enum O_SYNC         = 0x101000; // octal 04010000
         enum O_DSYNC        = 0x1000;   // octal   010000
         enum O_RSYNC        = O_SYNC;
+
+        enum O_DIRECTORY    = 0x004000; // octal    040000
+        enum O_NOFOLLOW     = 0x008000; // octal   0100000
+        enum O_DIRECT       = 0x020000; // octal   0400000
+        version (D_LP64)
+            enum O_LARGEFILE = 0;
+        else
+            enum O_LARGEFILE = 0x10000; // octal   0200000
+        enum O_TMPFILE      = 0x404000; // octal 020040000
+        enum O_ASYNC        = 0x2000;   // octal    020000
+        enum O_NOATIME      = 0x40000;  // octal  01000000
+        enum O_PATH         = 0x200000;
+        enum O_NDELAY       = O_NONBLOCK;
     }
     else version (ARM_Any)
     {
@@ -219,6 +270,19 @@ version (CRuntime_Glibc)
         enum O_SYNC         = 0x101000; // octal 04010000
         enum O_DSYNC        = 0x1000;   // octal   010000
         enum O_RSYNC        = O_SYNC;
+
+        enum O_DIRECTORY    = 0x004000; // octal    040000
+        enum O_NOFOLLOW     = 0x008000; // octal   0100000
+        enum O_DIRECT       = 0x010000; // octal   0200000
+        version (D_LP64)
+            enum O_LARGEFILE = 0;
+        else
+            enum O_LARGEFILE = 0x20000; // octal   0400000
+        enum O_TMPFILE      = 0x404000; // octal 020040000
+        enum O_ASYNC        = 0x2000;   // octal    020000
+        enum O_NOATIME      = 0x40000;  // octal  01000000
+        enum O_PATH         = 0x200000; // octal 010000000
+        enum O_NDELAY       = O_NONBLOCK;
     }
     else version (RISCV_Any)
     {
@@ -233,6 +297,19 @@ version (CRuntime_Glibc)
         enum O_SYNC         = 0x101000; // octal 04010000
         enum O_DSYNC        = 0x1000;   // octal   010000
         enum O_RSYNC        = O_SYNC;
+
+        enum O_DIRECTORY    = 0x010000;
+        enum O_NOFOLLOW     = 0x020000;
+        enum O_DIRECT       = 0x004000;
+        version (D_LP64)
+            enum O_LARGEFILE = 0;
+        else
+            enum O_LARGEFILE = 0x8000;
+        enum O_TMPFILE      = 0x410000;
+        enum O_ASYNC        = 0x2000;
+        enum O_NOATIME      = 0x40000;
+        enum O_PATH         = 0x200000;
+        enum O_NDELAY       = O_NONBLOCK;
     }
     else version (SPARC_Any)
     {
@@ -247,6 +324,19 @@ version (CRuntime_Glibc)
         enum O_SYNC         = 0x802000;
         enum O_DSYNC        = 0x2000;
         enum O_RSYNC        = O_SYNC;
+
+        enum O_DIRECTORY    = 0x10000;
+        enum O_NOFOLLOW     = 0x20000;
+        enum O_DIRECT       = 0x100000;
+        version (D_LP64)
+            enum O_LARGEFILE = 0;
+        else
+            enum O_LARGEFILE = 0x40000;
+        enum O_TMPFILE      = 0x2010000;
+        enum O_ASYNC        = 0x0040;
+        enum O_NOATIME      = 0x200000;
+        enum O_PATH         = 0x1000000;
+        enum O_NDELAY       = (0x0004|O_NONBLOCK);
     }
     else version (IBMZ_Any)
     {
@@ -261,11 +351,33 @@ version (CRuntime_Glibc)
         enum O_SYNC         = 0x101000; // octal 04010000
         enum O_DSYNC        = 0x1000;   // octal   010000
         enum O_RSYNC        = O_SYNC;
+
+        enum O_DIRECTORY    = 0x010000; // octal   0200000
+        enum O_NOFOLLOW     = 0x020000; // octal   0400000
+        enum O_DIRECT       = 0x004000; // octal    040000
+        version (D_LP64)
+            enum O_LARGEFILE = 0;
+        else
+            enum O_LARGEFILE = 0x08000; // octal   0100000
+        enum O_TMPFILE      = 0x410000; // octal 020200000
+        enum O_ASYNC        = 0x2000;   // octal    020000
+        enum O_NOATIME      = 0x40000;  // octal  01000000
+        enum O_PATH         = 0x200000; // octal 010000000
+        enum O_NDELAY       = O_NONBLOCK;
     }
     else
         static assert(0, "unimplemented");
 
-    enum O_ACCMODE      = 0x3;
+    version (CRuntime_Musl)
+    {
+        enum O_SEARCH   = O_PATH;
+        enum O_EXEC     = O_PATH;
+        enum O_ACCMODE  = (3|O_SEARCH);
+    }
+    else
+    {
+        enum O_ACCMODE  = 0x3;
+    }
     enum O_RDONLY       = 0x0;
     enum O_WRONLY       = 0x1;
     enum O_RDWR         = 0x2;
@@ -279,22 +391,11 @@ version (CRuntime_Glibc)
         pid_t   l_pid;
     }
 
-    static if ( __USE_FILE_OFFSET64 )
-    {
-        int   creat64(const scope char*, mode_t);
-        alias creat64 creat;
-
-        int   open64(const scope char*, int, ...);
-        alias open64 open;
-    }
-    else
-    {
-        int   creat(const scope char*, mode_t);
-        int   open(const scope char*, int, ...);
-    }
-
     enum AT_SYMLINK_NOFOLLOW = 0x100;
     enum AT_FDCWD = -100;
+    enum AT_REMOVEDIR = 0x200;
+    enum AT_SYMLINK_FOLLOW = 0x400;
+    enum AT_EACCESS = 0x200;
 }
 else version (Darwin)
 {
@@ -339,9 +440,6 @@ else version (Darwin)
         short   l_type;
         short   l_whence;
     }
-
-    int creat(const scope char*, mode_t);
-    int open(const scope char*, int, ...);
 }
 else version (FreeBSD)
 {
@@ -401,9 +499,6 @@ else version (FreeBSD)
         short   l_whence;
     }
 
-    int creat(const scope char*, mode_t);
-    int open(const scope char*, int, ...);
-
     enum AT_SYMLINK_NOFOLLOW = 0x200;
     enum AT_FDCWD = -100;
 }
@@ -466,9 +561,6 @@ else version (OpenBSD)
         short   l_whence;
     }
 
-    int creat(const scope char*, mode_t);
-    int open(const scope char*, int, ...);
-
     enum AT_FDCWD            = -100;
 
     enum AT_EACCESS          = 0x01;
@@ -524,10 +616,6 @@ else version (NetBSD)
         short   l_type;
         short   l_whence;
     }
-
-
-    int creat(const scope char*, mode_t);
-    int open(const scope char*, int, ...);
 }
 else version (DragonFlyBSD)
 {
@@ -612,11 +700,6 @@ else version (DragonFlyBSD)
     }
 
     alias oflock = flock;
-
-    int creat(const scope char*, mode_t);
-    int open(const scope char*, int, ...);
-    //int fcntl(int, int, ...);  /*defined below*/
-    //int flock(int, int);
 }
 else version (Solaris)
 {
@@ -700,7 +783,60 @@ else version (Solaris)
             c_long[4]   l_pad;
         }
     }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+/*
+int creat(const scope char*, mode_t);
+int fcntl(int, int, ...);
+int open(const scope char*, int, ...);
+*/
+version (CRuntime_Glibc)
+{
+    static if ( __USE_FILE_OFFSET64 )
+    {
+        int   creat64(const scope char*, mode_t);
+        alias creat64 creat;
 
+        int   open64(const scope char*, int, ...);
+        alias open64 open;
+    }
+    else
+    {
+        int   creat(const scope char*, mode_t);
+        int   open(const scope char*, int, ...);
+    }
+}
+else version (Darwin)
+{
+    int creat(const scope char*, mode_t);
+    int open(const scope char*, int, ...);
+}
+else version (FreeBSD)
+{
+    int creat(const scope char*, mode_t);
+    int open(const scope char*, int, ...);
+}
+else version (OpenBSD)
+{
+    int creat(const scope char*, mode_t);
+    int open(const scope char*, int, ...);
+}
+else version (NetBSD)
+{
+    int creat(const scope char*, mode_t);
+    int open(const scope char*, int, ...);
+}
+else version (DragonFlyBSD)
+{
+    int creat(const scope char*, mode_t);
+    int open(const scope char*, int, ...);
+}
+else version (Solaris)
+{
     version (D_LP64)
     {
         int creat(const scope char*, mode_t);
@@ -731,323 +867,15 @@ else version (Solaris)
 }
 else version (CRuntime_Bionic)
 {
-    // All these except for the two functions open and creat really come from
-    // the linux kernel and can probably be merged.
-    enum F_DUPFD        = 0;
-    enum F_GETFD        = 1;
-    enum F_SETFD        = 2;
-    enum F_GETFL        = 3;
-    enum F_SETFL        = 4;
-    enum F_GETLK        = 5;
-    enum F_SETLK        = 6;
-    enum F_SETLKW       = 7;
-    enum F_SETOWN       = 8;
-    enum F_GETOWN       = 9;
-
-    enum FD_CLOEXEC     = 1;
-
-    enum F_RDLCK        = 0;
-    enum F_WRLCK        = 1;
-    enum F_UNLCK        = 2;
-
-    enum O_CREAT        = 0x40;     // octal     0100
-    enum O_EXCL         = 0x80;     // octal     0200
-    enum O_NOCTTY       = 0x100;    // octal     0400
-    enum O_TRUNC        = 0x200;    // octal    01000
-
-    enum O_APPEND       = 0x400;    // octal    02000
-    enum O_NONBLOCK     = 0x800;    // octal    04000
-
-    version (D_LP64)
-    {
-        enum O_SYNC     = 0x101000; // octal 04010000
-    }
-    else
-    {
-        enum O_SYNC     = 0x1000;   // octal   010000
-    }
-
-    enum O_ACCMODE      = 0x3;
-    enum O_RDONLY       = 0x0;
-    enum O_WRONLY       = 0x1;
-    enum O_RDWR         = 0x2;
-
-    struct flock
-    {
-        short   l_type;
-        short   l_whence;
-        off_t   l_start;
-        off_t   l_len;
-        pid_t   l_pid;
-    }
-
     int   creat(const scope char*, mode_t);
     int   open(const scope char*, int, ...);
-
-    enum AT_FDCWD = -100;
 }
 else version (CRuntime_Musl)
 {
-    version (X86_64)
-    {
-        enum
-        {
-            O_DIRECTORY     = 0x010000, // octal   0200000
-            O_NOFOLLOW      = 0x020000, // octal   0400000
-            O_DIRECT        = 0x004000, // octal    040000
-            O_LARGEFILE     =        0,
-            O_TMPFILE       = 0x410000, // octal 020200000
-
-            F_GETLK        = 5,
-            F_SETLK        = 6,
-            F_SETLKW       = 7,
-        }
-    }
-    // Note: Definitions for i386 are in arch/generic/bits/fcntl.h
-    else version (X86)
-    {
-        enum
-        {
-            O_DIRECTORY     = 0x010000, // octal   0200000
-            O_NOFOLLOW      = 0x020000, // octal   0400000
-            O_DIRECT        = 0x004000, // octal    040000
-            O_LARGEFILE     = 0x008000, // octal   0100000
-            O_TMPFILE       = 0x410000, // octal 020200000
-
-            F_GETLK        = 12,
-            F_SETLK        = 13,
-            F_SETLKW       = 14,
-        }
-    }
-    else version (ARM)
-    {
-        enum
-        {
-            O_DIRECTORY     = 0x004000, // octal    040000
-            O_NOFOLLOW      = 0x008000, // octal   0100000
-            O_DIRECT        = 0x010000, // octal   0200000
-            O_LARGEFILE     = 0x020000, // octal   0400000
-            O_TMPFILE       = 0x404000, // octal 020040000
-
-            F_GETLK        = 12,
-            F_SETLK        = 13,
-            F_SETLKW       = 14,
-        }
-    }
-    else version (AArch64)
-    {
-        enum
-        {
-            O_DIRECTORY     = 0x004000, // octal    040000
-            O_NOFOLLOW      = 0x008000, // octal   0100000
-            O_DIRECT        = 0x010000, // octal   0200000
-            O_LARGEFILE     = 0x020000, // octal   0400000
-            O_TMPFILE       = 0x404000, // octal 020040000
-
-            F_GETLK        = 5,
-            F_SETLK        = 6,
-            F_SETLKW       = 7,
-        }
-    }
-    else version (SystemZ)
-    {
-        enum
-        {
-            O_DIRECTORY     = 0x010000, // octal   0200000
-            O_NOFOLLOW      = 0x020000, // octal   0400000
-            O_DIRECT        = 0x004000, // octal    040000
-            O_LARGEFILE     = 0x008000, // octal   0100000
-            O_TMPFILE       = 0x410000, // octal 020200000
-
-            F_GETLK        = 5,
-            F_SETLK        = 6,
-            F_SETLKW       = 7,
-        }
-    }
-    else version (PPC64)
-    {
-        enum
-        {
-            O_DIRECTORY     = 0x004000, // octal    040000
-            O_NOFOLLOW      = 0x008000, // octal   0100000
-            O_DIRECT        = 0x020000, // octal   0400000
-            O_LARGEFILE     = 0x010000, // octal   0200000
-            O_TMPFILE       = 0x410000, // octal 020200000
-
-            F_GETLK        = 5,
-            F_SETLK        = 6,
-            F_SETLKW       = 7,
-        }
-    }
-    else
-        static assert(0, "Platform not supported");
-
-    enum
-    {
-        O_CREAT         = 0x40,     // octal     0100
-        O_EXCL          = 0x80,     // octal     0200
-        O_NOCTTY        = 0x100,    // octal     0400
-        O_TRUNC         = 0x200,    // octal    01000
-
-        O_APPEND        = 0x400,    // octal    02000
-        O_NONBLOCK      = 0x800,    // octal    04000
-        O_DSYNC         = 0x1000,   // octal   010000
-        O_SYNC          = 0x101000, // octal 04010000
-        O_RSYNC         = O_SYNC,
-        O_CLOEXEC       = 0x80000,
-
-        O_ASYNC         = 0x2000,
-        O_NOATIME       = 0x40000,
-        O_PATH          = 0x200000,
-        O_NDELAY        = O_NONBLOCK,
-        O_SEARCH        = O_PATH,
-        O_EXEC          = O_PATH,
-
-        O_ACCMODE       = (3|O_SEARCH),
-        O_RDONLY        = 0,
-        O_WRONLY        = 1,
-        O_RDWR          = 2,
-    }
-    enum
-    {
-        F_DUPFD        = 0,
-        F_GETFD        = 1,
-        F_SETFD        = 2,
-        F_GETFL        = 3,
-        F_SETFL        = 4,
-        // F_GETLK, F_SETLK, F_SETLKW are arch-specific
-        F_SETOWN       = 8,
-        F_GETOWN       = 9,
-    }
-    enum
-    {
-        F_RDLCK        = 0,
-        F_WRLCK        = 1,
-        F_UNLCK        = 2,
-    }
-    struct flock
-    {
-        short   l_type;
-        short   l_whence;
-        off_t   l_start;
-        off_t   l_len;
-        pid_t   l_pid;
-    }
-    enum FD_CLOEXEC     = 1;
     int open(const scope char*, int, ...);
-
-    enum AT_FDCWD = -100;
-    enum AT_SYMLINK_NOFOLLOW = 0x100;
-    enum AT_REMOVEDIR = 0x200;
-    enum AT_SYMLINK_FOLLOW = 0x400;
-    enum AT_EACCESS = 0x200;
 }
 else version (CRuntime_UClibc)
 {
-    enum F_DUPFD        = 0;
-    enum F_GETFD        = 1;
-    enum F_SETFD        = 2;
-    enum F_GETFL        = 3;
-    enum F_SETFL        = 4;
-
-    version (X86_64)
-    {
-        enum F_GETLK        = 5;
-        enum F_SETLK        = 6;
-        enum F_SETLKW       = 7;
-    }
-    else static if (__USE_FILE_OFFSET64)
-    {
-        enum F_GETLK        = 5;
-        enum F_SETLK        = 6;
-        enum F_SETLKW       = 7;
-    }
-    else
-    {
-        enum F_GETLK        = 12;
-        enum F_SETLK        = 13;
-        enum F_SETLKW       = 14;
-    }
-
-    enum F_GETOWN       = 9;
-    enum F_SETOWN       = 8;
-
-    enum FD_CLOEXEC     = 1;
-
-    enum F_RDLCK        = 0;
-    enum F_UNLCK        = 2;
-    enum F_WRLCK        = 1;
-
-    version (X86_Any)
-    {
-        enum O_CREAT        = 0x40;     // octal     0100
-        enum O_EXCL         = 0x80;     // octal     0200
-        enum O_NOCTTY       = 0x100;    // octal     0400
-        enum O_TRUNC        = 0x200;    // octal    01000
-
-        enum O_APPEND       = 0x400;    // octal    02000
-        enum O_NONBLOCK     = 0x800;    // octal    04000
-        enum O_CLOEXEC      = 0x80000;  // octal    02000000
-        enum O_SYNC         = 0x1000;   // octal    010000
-        enum O_NDELAY       = O_NONBLOCK;
-        enum O_FSYNC        = O_SYNC;
-        enum O_ASYNC        = 0x2000;   // octal    020000
-    }
-    else version (MIPS_Any)
-    {
-        enum O_CREAT        = 0x0100;
-        enum O_EXCL         = 0x0400;
-        enum O_NOCTTY       = 0x0800;
-        enum O_TRUNC        = 0x0200;
-
-        enum O_APPEND       = 0x0008;
-        enum O_SYNC         = 0x0010;
-        enum O_NONBLOCK     = 0x0080;
-        enum O_CLOEXEC      = 0x80000;  // octal    02000000
-        enum O_NDELAY       = O_NONBLOCK;
-        enum O_FSYNC        = O_SYNC;
-        enum O_ASYNC        = 0x1000;
-    }
-    else version (ARM_Any)
-    {
-        enum O_CREAT        = 0x40;     // octal     0100
-        enum O_EXCL         = 0x80;     // octal     0200
-        enum O_NOCTTY       = 0x100;    // octal     0400
-        enum O_TRUNC        = 0x200;    // octal    01000
-
-        enum O_APPEND       = 0x400;    // octal    02000
-        enum O_NONBLOCK     = 0x800;    // octal    04000
-        enum O_CLOEXEC      = 0x80000;  // octal    02000000
-        enum O_SYNC         = 0x1000;   // octal    010000
-        enum O_NDELAY       = O_NONBLOCK;
-        enum O_FSYNC        = O_SYNC;
-        enum O_ASYNC        = 0x2000;     // octal 020000
-    }
-    else
-        static assert(0, "unimplemented");
-
-    enum O_ACCMODE      = 0x3;
-    enum O_RDONLY       = 0x0;
-    enum O_WRONLY       = 0x1;
-    enum O_RDWR         = 0x2;
-
-    struct flock
-    {
-        short   l_type;
-        short   l_whence;
-        static if (__USE_FILE_OFFSET64)
-        {
-            off64_t   l_start;
-            off64_t   l_len;
-        }
-        else
-        {
-            off_t   l_start;
-            off_t   l_len;
-        }
-        pid_t   l_pid;
-    }
-
     static if ( __USE_FILE_OFFSET64 )
     {
         int   creat64(const scope char*, mode_t);
@@ -1061,9 +889,6 @@ else version (CRuntime_UClibc)
         int   creat(const scope char*, mode_t);
         int   open(const scope char*, int, ...);
     }
-
-    enum AT_SYMLINK_NOFOLLOW    = 0x100;
-    enum AT_FDCWD               = -100;
 }
 else
 {
diff --git a/libphobos/libdruntime/core/sys/posix/poll.d b/libphobos/libdruntime/core/sys/posix/poll.d
index fdc41764a78..7c2d5705e4f 100644
--- a/libphobos/libdruntime/core/sys/posix/poll.d
+++ b/libphobos/libdruntime/core/sys/posix/poll.d
@@ -44,17 +44,6 @@ struct pollfd
 
 nfds_t
 
-POLLIN
-POLLRDNORM
-POLLRDBAND
-POLLPRI
-POLLOUT
-POLLWRNORM
-POLLWRBAND
-POLLERR
-POLLHUP
-POLLNVAL
-
 int poll(pollfd[], nfds_t, int);
 */
 
@@ -69,6 +58,145 @@ version (CRuntime_Glibc)
 
     alias c_ulong nfds_t;
 
+    int poll(pollfd*, nfds_t, int);
+}
+else version (Darwin)
+{
+    struct pollfd
+    {
+        int     fd;
+        short   events;
+        short   revents;
+    }
+
+    alias uint nfds_t;
+
+    int poll(pollfd*, nfds_t, int);
+}
+else version (FreeBSD)
+{
+    alias uint nfds_t;
+
+    struct pollfd
+    {
+        int     fd;
+        short   events;
+        short   revents;
+    }
+
+    int poll(pollfd*, nfds_t, int);
+}
+else version (NetBSD)
+{
+    alias uint nfds_t;
+
+    struct pollfd
+    {
+        int     fd;
+        short   events;
+        short   revents;
+    }
+
+    int poll(pollfd*, nfds_t, int);
+}
+else version (OpenBSD)
+{
+    alias uint nfds_t;
+
+    struct pollfd
+    {
+        int     fd;
+        short   events;
+        short   revents;
+    }
+
+    int poll(pollfd*, nfds_t, int);
+}
+else version (DragonFlyBSD)
+{
+    alias uint nfds_t;
+
+    struct pollfd
+    {
+        int     fd;
+        short   events;
+        short   revents;
+    }
+
+    int poll(pollfd*, nfds_t, int);
+}
+else version (Solaris)
+{
+    alias c_ulong nfds_t;
+
+    struct pollfd
+    {
+        int     fd;
+        short   events;
+        short   revents;
+    }
+
+    int poll(pollfd*, nfds_t, int);
+}
+else version (CRuntime_Bionic)
+{
+    struct pollfd
+    {
+        int     fd;
+        short   events;
+        short   revents;
+    }
+
+    alias uint nfds_t;
+
+    int poll(pollfd*, nfds_t, c_long);
+}
+else version (CRuntime_Musl)
+{
+    struct pollfd
+    {
+        int     fd;
+        short   events;
+        short   revents;
+    }
+
+    alias uint nfds_t;
+
+    int poll(pollfd*, nfds_t, c_long);
+}
+else version (CRuntime_UClibc)
+{
+    struct pollfd
+    {
+        int     fd;
+        short   events;
+        short   revents;
+    }
+
+    alias c_ulong nfds_t;
+
+    int poll(pollfd*, nfds_t, int);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+/*
+POLLIN
+POLLRDNORM
+POLLRDBAND
+POLLPRI
+POLLOUT
+POLLWRNORM
+POLLWRBAND
+POLLERR
+POLLHUP
+POLLNVAL
+*/
+
+version (linux)
+{
     enum
     {
         POLLIN      = 0x001,
@@ -82,20 +210,9 @@ version (CRuntime_Glibc)
         POLLHUP     = 0x010,
         POLLNVAL    = 0x020,
     }
-
-    int poll(pollfd*, nfds_t, int);
 }
 else version (Darwin)
 {
-    struct pollfd
-    {
-        int     fd;
-        short   events;
-        short   revents;
-    }
-
-    alias uint nfds_t;
-
     enum
     {
         POLLIN      = 0x0001,
@@ -116,20 +233,9 @@ else version (Darwin)
         POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
                         POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
     }
-
-    int poll(pollfd*, nfds_t, int);
 }
 else version (FreeBSD)
 {
-    alias uint nfds_t;
-
-    struct pollfd
-    {
-        int     fd;
-        short   events;
-        short   revents;
-    }
-
     enum
     {
         POLLIN      = 0x0001,
@@ -150,20 +256,9 @@ else version (FreeBSD)
         POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
         POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
     }
-
-    int poll(pollfd*, nfds_t, int);
 }
 else version (NetBSD)
 {
-    alias uint nfds_t;
-
-    struct pollfd
-    {
-        int     fd;
-        short   events;
-        short   revents;
-    }
-
     enum
     {
         POLLIN      = 0x0001,
@@ -184,20 +279,9 @@ else version (NetBSD)
         POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
         POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
     }
-
-    int poll(pollfd*, nfds_t, int);
 }
 else version (OpenBSD)
 {
-    alias uint nfds_t;
-
-    struct pollfd
-    {
-        int     fd;
-        short   events;
-        short   revents;
-    }
-
     enum
     {
         POLLIN      = 0x0001,
@@ -215,20 +299,9 @@ else version (OpenBSD)
         POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
         POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
     }
-
-    int poll(pollfd*, nfds_t, int);
 }
 else version (DragonFlyBSD)
 {
-    alias uint nfds_t;
-
-    struct pollfd
-    {
-        int     fd;
-        short   events;
-        short   revents;
-    }
-
     enum
     {
         POLLIN      = 0x0001,
@@ -249,20 +322,9 @@ else version (DragonFlyBSD)
         POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
         POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
     }
-
-    int poll(pollfd*, nfds_t, int);
 }
 else version (Solaris)
 {
-    alias c_ulong nfds_t;
-
-    struct pollfd
-    {
-        int     fd;
-        short   events;
-        short   revents;
-    }
-
     enum
     {
         POLLIN      = 0x0001,
@@ -276,90 +338,8 @@ else version (Solaris)
         POLLHUP     = 0x0010,
         POLLNVAL    = 0x0020,
     }
-
-    int poll(pollfd*, nfds_t, int);
 }
-else version (CRuntime_Bionic)
+else
 {
-    struct pollfd
-    {
-        int     fd;
-        short   events;
-        short   revents;
-    }
-
-    alias uint nfds_t;
-
-    enum
-    {
-        POLLIN      = 0x001,
-        POLLRDNORM  = 0x040,
-        POLLRDBAND  = 0x080,
-        POLLPRI     = 0x002,
-        POLLOUT     = 0x004,
-        POLLWRNORM  = 0x100,
-        POLLWRBAND  = 0x200,
-        POLLERR     = 0x008,
-        POLLHUP     = 0x010,
-        POLLNVAL    = 0x020,
-    }
-
-    int poll(pollfd*, nfds_t, c_long);
-}
-else version (CRuntime_Musl)
-{
-    struct pollfd
-    {
-        int     fd;
-        short   events;
-        short   revents;
-    }
-
-    alias uint nfds_t;
-
-    enum
-    {
-        POLLIN      = 0x001,
-        POLLPRI     = 0x002,
-        POLLOUT     = 0x004,
-        POLLERR     = 0x008,
-        POLLHUP     = 0x010,
-        POLLNVAL    = 0x020,
-        POLLRDNORM  = 0x040,
-        POLLRDBAND  = 0x080,
-        POLLWRNORM  = 0x100,
-        POLLWRBAND  = 0x200,
-    }
-
-    int poll(pollfd*, nfds_t, c_long);
-}
-else version (CRuntime_UClibc)
-{
-    struct pollfd
-    {
-        int     fd;
-        short   events;
-        short   revents;
-    }
-
-    alias c_ulong nfds_t;
-
-    enum
-    {
-        POLLIN      = 0x001,
-        POLLRDNORM  = 0x040,
-        POLLRDBAND  = 0x080,
-        POLLPRI     = 0x002,
-        POLLOUT     = 0x004,
-        POLLWRNORM  = 0x100,
-        POLLWRBAND  = 0x200,
-        POLLMSG     = 0x400,
-        POLLREMOVE  = 0x1000,
-        POLLRDHUP   = 0x2000,
-        POLLERR     = 0x008,
-        POLLHUP     = 0x010,
-        POLLNVAL    = 0x020,
-    }
-
-    int poll(pollfd*, nfds_t, int);
+    static assert(false, "Unsupported platform");
 }
diff --git a/libphobos/libdruntime/core/sys/posix/sched.d b/libphobos/libdruntime/core/sys/posix/sched.d
index f9d286217fb..35463d4fb6c 100644
--- a/libphobos/libdruntime/core/sys/posix/sched.d
+++ b/libphobos/libdruntime/core/sys/posix/sched.d
@@ -58,27 +58,33 @@ int sched_setparam(pid_t, const scope sched_param*);
 int sched_setscheduler(pid_t, int, const scope sched_param*);
 */
 
-version (CRuntime_Glibc)
+version (linux)
 {
-    struct sched_param
+    version (CRuntime_Musl)
     {
-        int sched_priority;
+        struct sched_param
+        {
+            int sched_priority;
+            int __reserved1;
+            timespec[2] __reserved2;
+            int __reserved3;
+        }
+    }
+    else
+    {
+        struct sched_param
+        {
+            int sched_priority;
+        }
     }
 
     enum SCHED_OTHER    = 0;
     enum SCHED_FIFO     = 1;
     enum SCHED_RR       = 2;
     //SCHED_SPORADIC (SS|TSP)
-}
-else version (CRuntime_Musl)
-{
-    struct sched_param {
-        int sched_priority;
-        int sched_ss_low_priority;
-        timespec sched_ss_repl_period;
-        timespec sched_ss_init_budget;
-        int sched_ss_max_repl;
-    }
+    enum SCHED_BATCH    = 3;
+    enum SCHED_IDLE     = 5;
+    enum SCHED_RESET_ON_FORK = 0x40000000;
 }
 else version (Darwin)
 {
@@ -87,8 +93,6 @@ else version (Darwin)
     enum SCHED_RR       = 2;
     //SCHED_SPORADIC (SS|TSP)
 
-    private enum __SCHED_PARAM_SIZE__ = 4;
-
     struct sched_param
     {
         int                             sched_priority;
@@ -156,33 +160,6 @@ else version (Solaris)
     enum SCHED_FX = 6;
     enum _SCHED_NEXT = 7;
 }
-else version (CRuntime_Bionic)
-{
-    struct sched_param
-    {
-        int sched_priority;
-    }
-
-    enum SCHED_NORMAL   = 0;
-    enum SCHED_OTHER    = 0;
-    enum SCHED_FIFO     = 1;
-    enum SCHED_RR       = 2;
-}
-else version (CRuntime_UClibc)
-{
-    struct sched_param
-    {
-        int sched_priority;
-    }
-
-    enum SCHED_OTHER    = 0;
-    enum SCHED_FIFO     = 1;
-    enum SCHED_RR       = 2;
-    enum SCHED_BATCH    = 3;
-    enum SCHED_IDLE     = 5;
-
-    enum SCHED_RESET_ON_FORK    = 0x40000000;
-}
 else
 {
     static assert(false, "Unsupported platform");
diff --git a/libphobos/libdruntime/core/sys/posix/signal.d b/libphobos/libdruntime/core/sys/posix/signal.d
index 32e51561562..68aee980ef3 100644
--- a/libphobos/libdruntime/core/sys/posix/signal.d
+++ b/libphobos/libdruntime/core/sys/posix/signal.d
@@ -151,13 +151,15 @@ version (Solaris)
         return sig;
     }
 }
-else version (FreeBSD) {
+else version (FreeBSD)
+{
     // Note: it appears that FreeBSD (prior to 7) and OSX do not support realtime signals
     // https://github.com/freebsd/freebsd/blob/e79c62ff68fc74d88cb6f479859f6fae9baa5101/sys/sys/signal.h#L117
     enum SIGRTMIN = 65;
     enum SIGRTMAX = 126;
 }
-else version (DragonFlyBSD) {
+else version (DragonFlyBSD)
+{
     enum SIGRTMIN = 35;
     enum SIGRTMAX = 126;
 }
@@ -540,9 +542,54 @@ else
     static assert(false, "Unsupported platform");
 }
 
-version (CRuntime_Glibc)
+version (linux)
 {
-    version (SystemZ)
+    version (CRuntime_Musl)
+    {
+        struct sigaction_t
+        {
+            union
+            {
+                sigfn_t     sa_handler;
+                sigactfn_t  sa_sigaction;
+            }
+            sigset_t        sa_mask;
+            int             sa_flags;
+            void function() sa_restorer;
+        }
+    }
+    else version (CRuntime_Bionic)
+    {
+        version (D_LP64)
+        {
+            struct sigaction_t
+            {
+                int            sa_flags;
+                union
+                {
+                    sigfn_t    sa_handler;
+                    sigactfn_t sa_sigaction;
+                }
+                sigset_t        sa_mask;
+                void function() sa_restorer;
+        }
+        }
+        else
+        {
+            struct sigaction_t
+            {
+                union
+                {
+                    sigfn_t    sa_handler;
+                    sigactfn_t sa_sigaction;
+                }
+                sigset_t        sa_mask;
+                int             sa_flags;
+                void function() sa_restorer;
+            }
+        }
+    }
+    else version (SystemZ)
     {
         struct sigaction_t
         {
@@ -558,15 +605,22 @@ version (CRuntime_Glibc)
             {
                 sigfn_t     sa_handler;
             }
-            int             __glibc_reserved0;
-            int             sa_flags;
+            version (CRuntime_Glibc)
+            {
+                int         __glibc_reserved0;
+                int         sa_flags;
+            }
+            else
+            {
+                c_ulong     sa_flags;
+            }
 
             void function() sa_restorer;
 
             sigset_t        sa_mask;
         }
     }
-    else
+    else version (HPPA_Any)
     {
         struct sigaction_t
         {
@@ -582,33 +636,100 @@ version (CRuntime_Glibc)
             {
                 sigfn_t     sa_handler;
             }
+            version (CRuntime_Glibc)
+            {
+                version (D_LP64)
+                    int     __glibc_reserved0;
+                int         sa_flags;
+            }
+            else
+            {
+                c_ulong     sa_flags;
+            }
             sigset_t        sa_mask;
-            int             sa_flags;
+        }
+    }
+    else version (MIPS_Any)
+    {
+        struct sigaction_t
+        {
+            int sa_flags;
 
+            static if ( true /* __USE_POSIX199309 */ )
+            {
+                union
+                {
+                    sigfn_t     sa_handler;
+                    sigactfn_t  sa_sigaction;
+                }
+            }
+            else
+            {
+                sigfn_t     sa_handler;
+            }
+            sigset_t        sa_mask;
             void function() sa_restorer;
+
+            version (CRuntime_Glibc)
+            {
+                static if ((void*).sizeof < 8)
+                    int[1]  sa_resv;
+            }
         }
     }
-}
-else version (CRuntime_Musl)
-{
-    struct sigaction_t
+    else version (SPARC_Any)
     {
-        static if ( true /* __USE_POSIX199309 */ )
+        struct sigaction_t
         {
-            union
+            static if ( true /* __USE_POSIX199309 */ )
+            {
+                union
+                {
+                    sigfn_t     sa_handler;
+                    sigactfn_t  sa_sigaction;
+                }
+            }
+            else
             {
                 sigfn_t     sa_handler;
-                sigactfn_t  sa_sigaction;
+            }
+            version (CRuntime_Glibc)
+            {
+                sigset_t    sa_mask;
+                version (D_LP64)
+                    int     __glibc_reserved0;
+                int         sa_flags;
+                void function() sa_restorer;
+            }
+            else
+            {
+                c_ulong     sa_flags;
+                void function() sa_restorer;
+                sigset_t    sa_mask;
             }
         }
-        else
+    }
+    else
+    {
+        struct sigaction_t
         {
-            sigfn_t     sa_handler;
-        }
-        sigset_t        sa_mask;
-        int             sa_flags;
+            static if ( true /* __USE_POSIX199309 */ )
+            {
+                union
+                {
+                    sigfn_t     sa_handler;
+                    sigactfn_t  sa_sigaction;
+                }
+            }
+            else
+            {
+                sigfn_t     sa_handler;
+            }
+            sigset_t        sa_mask;
+            int             sa_flags;
 
-        void function() sa_restorer;
+            void function() sa_restorer;
+        }
     }
 }
 else version (FreeBSD)
@@ -683,91 +804,6 @@ else version (Solaris)
             int[2] sa_resv;
     }
 }
-else version (CRuntime_UClibc)
-{
-    version (ARM)           version = sigaction_common;
-    else version (X86_64)   version = sigaction_common;
-
-    version (sigaction_common)
-    {
-        struct sigaction_t
-        {
-            static if ( true /* __USE_POSIX199309 */ )
-            {
-                union
-                {
-                    sigfn_t     sa_handler;
-                    sigactfn_t  sa_sigaction;
-                }
-            }
-            else
-            {
-                sigfn_t     sa_handler;
-            }
-            c_ulong     sa_flags;
-            void function() sa_restorer;
-            sigset_t    sa_mask;
-        }
-    }
-    else version (MIPS32)
-    {
-        struct sigaction_t
-        {
-            uint     sa_flags;
-            static if ( true /* __USE_POSIX199309 */ )
-            {
-                union
-                {
-                    sigfn_t     sa_handler;
-                    sigactfn_t  sa_sigaction;
-                }
-            }
-            else
-            {
-                sigfn_t     sa_handler;
-            }
-            sigset_t    sa_mask;
-            void function() sa_restorer;
-        }
-    }
-    else
-    {
-        static assert(false, "Architecture not supported.");
-    }
-}
-else version (CRuntime_Bionic)
-{
-    version (D_LP64)
-    {
-        struct sigaction_t
-        {
-            int            sa_flags;
-            union
-            {
-                sigfn_t    sa_handler;
-                sigactfn_t sa_sigaction;
-            }
-
-            sigset_t        sa_mask;
-            void function() sa_restorer;
-        }
-    }
-    else
-    {
-        struct sigaction_t
-        {
-            union
-            {
-                sigfn_t    sa_handler;
-                sigactfn_t sa_sigaction;
-            }
-
-            sigset_t        sa_mask;
-            int             sa_flags;
-            void function() sa_restorer;
-        }
-    }
-}
 else version (Darwin)
 {
     struct sigaction_t
@@ -839,26 +875,14 @@ SI_QUEUE
 SI_TIMER
 SI_ASYNCIO
 SI_MESGQ
-
-int kill(pid_t, int);
-int sigaction(int, const scope sigaction_t*, sigaction_t*);
-int sigaddset(sigset_t*, int);
-int sigdelset(sigset_t*, int);
-int sigemptyset(sigset_t*);
-int sigfillset(sigset_t*);
-int sigismember(const scope sigset_t*, int);
-int sigpending(sigset_t*);
-int sigprocmask(int, const scope sigset_t*, sigset_t*);
-int sigsuspend(const scope sigset_t*);
-int sigwait(const scope sigset_t*, int*);
 */
 
 nothrow @nogc
 {
 
-version (CRuntime_Glibc)
+version (linux)
 {
-    enum SIG_HOLD = cast(sigfn_t2) 1;
+    enum SIG_HOLD = cast(sigfn_t2) 2;
 
     private enum _SIGSET_NWORDS = 1024 / (8 * c_ulong.sizeof);
 
@@ -867,20 +891,26 @@ version (CRuntime_Glibc)
         c_ulong[_SIGSET_NWORDS] __val;
     }
 
-    // pid_t  (defined in core.sys.types)
-
-    //SIGABRT (defined in core.stdc.signal)
-    //SIGFPE  (defined in core.stdc.signal)
-    //SIGILL  (defined in core.stdc.signal)
-    //SIGINT  (defined in core.stdc.signal)
-    //SIGSEGV (defined in core.stdc.signal)
-    //SIGTERM (defined in core.stdc.signal)
-
     enum SA_NOCLDSTOP   = 1; // (CX|XSI)
 
-    enum SIG_BLOCK      = 0;
-    enum SIG_UNBLOCK    = 1;
-    enum SIG_SETMASK    = 2;
+    version (MIPS_Any)
+    {
+        enum SIG_BLOCK      = 1;
+        enum SIG_UNBLOCK    = 2;
+        enum SIG_SETMASK    = 3;
+    }
+    else version (SPARC_Any)
+    {
+        enum SIG_BLOCK      = 1;
+        enum SIG_UNBLOCK    = 2;
+        enum SIG_SETMASK    = 4;
+    }
+    else
+    {
+        enum SIG_BLOCK      = 0;
+        enum SIG_UNBLOCK    = 1;
+        enum SIG_SETMASK    = 2;
+    }
 
     private enum __SI_MAX_SIZE = 128;
 
@@ -895,10 +925,17 @@ version (CRuntime_Glibc)
 
     struct siginfo_t
     {
-        int si_signo;       // Signal number
-        int si_errno;       // If non-zero, an errno value associated with
-                            // this signal, as defined in <errno.h>
-        int si_code;        // Signal code
+        int si_signo;
+        version (MIPS_Any)  // __SI_SWAP_ERRNO_CODE
+        {
+            int si_code;
+            int si_errno;
+        }
+        else
+        {
+            int si_errno;
+            int si_code;
+        }
 
         union _sifields_t
         {
@@ -907,32 +944,31 @@ version (CRuntime_Glibc)
             // kill()
             struct _kill_t
             {
-                pid_t si_pid; // Sending process ID
-                uid_t si_uid; // Real user ID of sending process
+                pid_t si_pid;
+                uid_t si_uid;
             } _kill_t _kill;
-
             // POSIX.1b timers.
             struct _timer_t
             {
-                int    si_tid;     // Timer ID
-                int    si_overrun; // Overrun count
-                sigval si_sigval;  // Signal value
+                int    si_tid;
+                int    si_overrun;
+                sigval si_sigval;
             } _timer_t _timer;
 
             // POSIX.1b signals
             struct _rt_t
             {
-                pid_t  si_pid;    // Sending process ID
-                uid_t  si_uid;    // Real user ID of sending process
-                sigval si_sigval; // Signal value
+                pid_t  si_pid;
+                uid_t  si_uid;
+                sigval si_sigval;
             } _rt_t _rt;
 
             // SIGCHLD
             struct _sigchild_t
             {
-                pid_t   si_pid;    // Which child
-                uid_t   si_uid;    // Real user ID of sending process
-                int     si_status; // Exit value or signal
+                pid_t   si_pid;
+                uid_t   si_uid;
+                int     si_status;
                 clock_t si_utime;
                 clock_t si_stime;
             } _sigchild_t _sigchld;
@@ -940,13 +976,13 @@ version (CRuntime_Glibc)
             // SIGILL, SIGFPE, SIGSEGV, SIGBUS
             struct _sigfault_t
             {
-                void*     si_addr;  // Faulting insn/memory ref
+                void*     si_addr;
             } _sigfault_t _sigfault;
 
             // SIGPOLL
             struct _sigpoll_t
             {
-                c_long   si_band;   // Band event for SIGPOLL
+                c_long   si_band;
                 int      si_fd;
             } _sigpoll_t _sigpoll;
         } _sifields_t _sifields;
@@ -972,32 +1008,12 @@ version (CRuntime_Glibc)
         SI_USER,
         SI_KERNEL  = 0x80
     }
-
-    int kill(pid_t, int);
-    int sigaction(int, const scope sigaction_t*, sigaction_t*);
-    int sigaddset(sigset_t*, int);
-    int sigdelset(sigset_t*, int);
-    int sigemptyset(sigset_t*);
-    int sigfillset(sigset_t*);
-    int sigismember(const scope sigset_t*, int);
-    int sigpending(sigset_t*);
-    int sigprocmask(int, const scope sigset_t*, sigset_t*);
-    int sigsuspend(const scope sigset_t*);
-    int sigwait(const scope sigset_t*, int*);
 }
 else version (Darwin)
 {
     enum SIG_HOLD = cast(sigfn_t2) 5;
 
     alias uint sigset_t;
-    // pid_t  (defined in core.sys.types)
-
-    //SIGABRT (defined in core.stdc.signal)
-    //SIGFPE  (defined in core.stdc.signal)
-    //SIGILL  (defined in core.stdc.signal)
-    //SIGINT  (defined in core.stdc.signal)
-    //SIGSEGV (defined in core.stdc.signal)
-    //SIGTERM (defined in core.stdc.signal)
 
     enum SA_NOCLDSTOP = 8; // (CX|XSI)
 
@@ -1024,18 +1040,6 @@ else version (Darwin)
     enum SI_TIMER   = 0x10003;
     enum SI_ASYNCIO = 0x10004;
     enum SI_MESGQ   = 0x10005;
-
-    int kill(pid_t, int);
-    int sigaction(int, const scope sigaction_t*, sigaction_t*);
-    int sigaddset(sigset_t*, int);
-    int sigdelset(sigset_t*, int);
-    int sigemptyset(sigset_t*);
-    int sigfillset(sigset_t*);
-    int sigismember(const scope sigset_t*, int);
-    int sigpending(sigset_t*);
-    int sigprocmask(int, const scope sigset_t*, sigset_t*);
-    int sigsuspend(const scope sigset_t*);
-    int sigwait(const scope sigset_t*, int*);
 }
 else version (FreeBSD)
 {
@@ -1102,18 +1106,6 @@ else version (FreeBSD)
     enum SI_TIMER   = 0x10003;
     enum SI_ASYNCIO = 0x10004;
     enum SI_MESGQ   = 0x10005;
-
-    int kill(pid_t, int);
-    int sigaction(int, const scope sigaction_t*, sigaction_t*);
-    int sigaddset(sigset_t*, int);
-    int sigdelset(sigset_t*, int);
-    int sigemptyset(sigset_t *);
-    int sigfillset(sigset_t *);
-    int sigismember(const scope sigset_t*, int);
-    int sigpending(sigset_t *);
-    int sigprocmask(int, const scope sigset_t*, sigset_t*);
-    int sigsuspend(const scope sigset_t*);
-    int sigwait(const scope sigset_t*, int*);
 }
 else version (NetBSD)
 {
@@ -1188,28 +1180,6 @@ else version (NetBSD)
     enum SI_TIMER   = -2;
     enum SI_ASYNCIO = -3;
     enum SI_MESGQ   = -4;
-
-    int kill(pid_t, int);
-    int __sigaction14(int, const scope sigaction_t*, sigaction_t*);
-    int __sigaddset14(sigset_t*, int);
-    int __sigdelset14(sigset_t*, int);
-    int __sigemptyset14(sigset_t *);
-    int __sigfillset14(sigset_t *);
-    int __sigismember14(const scope sigset_t*, int);
-    int __sigpending14(sigset_t *);
-    int __sigprocmask14(int, const scope sigset_t*, sigset_t*);
-    int __sigsuspend14(const scope sigset_t*);
-    int sigwait(const scope sigset_t*, int*);
-
-    alias __sigaction14 sigaction;
-    alias __sigaddset14 sigaddset;
-    alias __sigdelset14 sigdelset;
-    alias __sigemptyset14 sigemptyset;
-    alias __sigfillset14 sigfillset;
-    alias __sigismember14 sigismember;
-    alias __sigpending14 sigpending;
-    alias __sigprocmask14 sigprocmask;
-    alias __sigsuspend14 sigsuspend;
 }
 else version (OpenBSD)
 {
@@ -1274,18 +1244,6 @@ else version (OpenBSD)
     enum SI_LWP    = -1;
     enum SI_QUEUE  = -2;
     enum SI_TIMER  = -3;
-
-    int kill(pid_t, int);
-    int sigaction(int, const scope sigaction_t*, sigaction_t*);
-    int sigaddset(sigset_t*, int);
-    int sigdelset(sigset_t*, int);
-    int sigemptyset(sigset_t *);
-    int sigfillset(sigset_t *);
-    int sigismember(const scope sigset_t*, int);
-    int sigpending(sigset_t *);
-    int sigprocmask(int, const scope sigset_t*, sigset_t*);
-    int sigsuspend(const scope sigset_t*);
-    int sigwait(const scope sigset_t*, int*);
 }
 else version (DragonFlyBSD)
 {
@@ -1323,18 +1281,6 @@ else version (DragonFlyBSD)
     enum SI_TIMER     = -2;
     enum SI_ASYNCIO   = -3;
     enum SI_MESGQ     = -4;
-
-    int kill(pid_t, int);
-    int sigaction(int, const scope sigaction_t*, sigaction_t*);
-    int sigaddset(sigset_t*, int);
-    int sigdelset(sigset_t*, int);
-    int sigemptyset(sigset_t *);
-    int sigfillset(sigset_t *);
-    int sigismember(const scope sigset_t*, int);
-    int sigpending(sigset_t *);
-    int sigprocmask(int, const scope sigset_t*, sigset_t*);
-    int sigsuspend(const scope sigset_t*);
-    int sigwait(const scope sigset_t*, int*);
 }
 else version (Solaris)
 {
@@ -1446,9 +1392,122 @@ else version (Solaris)
     enum SI_TIMER   = -3;
     enum SI_ASYNCIO = -4;
     enum SI_MESGQ   = -5;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
 
-    enum SIGIO = SIGPOLL;
+/*
+int kill(pid_t, int);
+int sigaction(int, const scope sigaction_t*, sigaction_t*);
+int sigaddset(sigset_t*, int);
+int sigdelset(sigset_t*, int);
+int sigemptyset(sigset_t*);
+int sigfillset(sigset_t*);
+int sigismember(const scope sigset_t*, int);
+int sigpending(sigset_t*);
+int sigprocmask(int, const scope sigset_t*, sigset_t*);
+int sigsuspend(const scope sigset_t*);
+int sigwait(const scope sigset_t*, int*);
+*/
+
+version (CRuntime_Glibc)
+{
+    int kill(pid_t, int);
+    int sigaction(int, const scope sigaction_t*, sigaction_t*);
+    int sigaddset(sigset_t*, int);
+    int sigdelset(sigset_t*, int);
+    int sigemptyset(sigset_t*);
+    int sigfillset(sigset_t*);
+    int sigismember(const scope sigset_t*, int);
+    int sigpending(sigset_t*);
+    int sigprocmask(int, const scope sigset_t*, sigset_t*);
+    int sigsuspend(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
+}
+else version (Darwin)
+{
+    int kill(pid_t, int);
+    int sigaction(int, const scope sigaction_t*, sigaction_t*);
+    int sigaddset(sigset_t*, int);
+    int sigdelset(sigset_t*, int);
+    int sigemptyset(sigset_t*);
+    int sigfillset(sigset_t*);
+    int sigismember(const scope sigset_t*, int);
+    int sigpending(sigset_t*);
+    int sigprocmask(int, const scope sigset_t*, sigset_t*);
+    int sigsuspend(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
+}
+else version (FreeBSD)
+{
+    int kill(pid_t, int);
+    int sigaction(int, const scope sigaction_t*, sigaction_t*);
+    int sigaddset(sigset_t*, int);
+    int sigdelset(sigset_t*, int);
+    int sigemptyset(sigset_t *);
+    int sigfillset(sigset_t *);
+    int sigismember(const scope sigset_t*, int);
+    int sigpending(sigset_t *);
+    int sigprocmask(int, const scope sigset_t*, sigset_t*);
+    int sigsuspend(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
+}
+else version (NetBSD)
+{
+    int kill(pid_t, int);
+    int __sigaction14(int, const scope sigaction_t*, sigaction_t*);
+    int __sigaddset14(sigset_t*, int);
+    int __sigdelset14(sigset_t*, int);
+    int __sigemptyset14(sigset_t *);
+    int __sigfillset14(sigset_t *);
+    int __sigismember14(const scope sigset_t*, int);
+    int __sigpending14(sigset_t *);
+    int __sigprocmask14(int, const scope sigset_t*, sigset_t*);
+    int __sigsuspend14(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
 
+    alias __sigaction14 sigaction;
+    alias __sigaddset14 sigaddset;
+    alias __sigdelset14 sigdelset;
+    alias __sigemptyset14 sigemptyset;
+    alias __sigfillset14 sigfillset;
+    alias __sigismember14 sigismember;
+    alias __sigpending14 sigpending;
+    alias __sigprocmask14 sigprocmask;
+    alias __sigsuspend14 sigsuspend;
+}
+else version (OpenBSD)
+{
+    int kill(pid_t, int);
+    int sigaction(int, const scope sigaction_t*, sigaction_t*);
+    int sigaddset(sigset_t*, int);
+    int sigdelset(sigset_t*, int);
+    int sigemptyset(sigset_t *);
+    int sigfillset(sigset_t *);
+    int sigismember(const scope sigset_t*, int);
+    int sigpending(sigset_t *);
+    int sigprocmask(int, const scope sigset_t*, sigset_t*);
+    int sigsuspend(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
+}
+else version (DragonFlyBSD)
+{
+    int kill(pid_t, int);
+    int sigaction(int, const scope sigaction_t*, sigaction_t*);
+    int sigaddset(sigset_t*, int);
+    int sigdelset(sigset_t*, int);
+    int sigemptyset(sigset_t *);
+    int sigfillset(sigset_t *);
+    int sigismember(const scope sigset_t*, int);
+    int sigpending(sigset_t *);
+    int sigprocmask(int, const scope sigset_t*, sigset_t*);
+    int sigsuspend(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
+}
+else version (Solaris)
+{
     int kill(pid_t, int);
     int sigaction(int, const scope sigaction_t*, sigaction_t*);
     int sigaddset(sigset_t*, int);
@@ -1467,101 +1526,15 @@ else version (CRuntime_Bionic)
     import core.stdc.string : memset;
 
     version (X86)
-    {
-        alias uint sigset_t;
         enum int LONG_BIT = 32;
-    }
     else version (ARM)
-    {
-        alias uint sigset_t;
         enum int LONG_BIT = 32;
-    }
     else version (AArch64)
-    {
-        struct sigset_t { ulong[1] sig; }
         enum int LONG_BIT = 64;
-    }
     else version (X86_64)
-    {
-        alias ulong sigset_t;
         enum int LONG_BIT = 64;
-    }
     else
-    {
         static assert(false, "Architecture not supported.");
-    }
-
-    enum SIG_BLOCK   = 0;
-    enum SIG_UNBLOCK = 1;
-    enum SIG_SETMASK = 2;
-
-    private enum SI_MAX_SIZE = 128;
-    private enum SI_PAD_SIZE = ((SI_MAX_SIZE / int.sizeof) - 3);
-
-    struct siginfo_t
-    {
-        int si_signo;
-        int si_errno;
-        int si_code;
-
-        union _sifields_t
-        {
-            int[SI_PAD_SIZE] _pad;
-
-            struct _kill_t
-            {
-                pid_t _pid;
-                uid_t _uid;
-            } _kill_t _kill;
-
-            struct _timer_t
-            {
-                timer_t _tid;
-                int     _overrun;
-                sigval  _sigval;
-                int     _sys_private;
-            } _timer_t _timer;
-
-            struct _rt_t
-            {
-                pid_t  _pid;
-                uid_t  _uid;
-                sigval _sigval;
-            } _rt_t _rt;
-
-            struct _sigchild_t
-            {
-                pid_t   _pid;
-                uid_t   _uid;
-                int     _status;
-                clock_t _utime;
-                clock_t _stime;
-            } _sigchild_t _sigchld;
-
-            struct _sigfault_t
-            {
-                void*   _addr;
-            } _sigfault_t _sigfault;
-
-            struct _sigpoll_t
-            {
-                c_long _band;
-                int    _fd;
-            } _sigpoll_t _sigpoll;
-        } _sifields_t _sifields;
-    }
-
-    enum
-    {
-        SI_TKILL   = -6,
-        SI_SIGIO,
-        SI_ASYNCIO,
-        SI_MESGQ,
-        SI_TIMER,
-        SI_QUEUE,
-        SI_USER,
-        SI_KERNEL  = 0x80
-    }
 
     int kill(pid_t, int);
     int sigaction(int, const scope sigaction_t*, sigaction_t*);
@@ -1601,111 +1574,6 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
-    struct sigset_t
-    {
-        c_ulong[128/c_long.sizeof] __bits;
-    }
-
-    version (MIPS_Any)
-    {
-        enum SIG_BLOCK      = 1;
-        enum SIG_UNBLOCK    = 2;
-        enum SIG_SETMASK    = 3;
-    }
-    else
-    {
-        enum SIG_BLOCK      = 0;
-        enum SIG_UNBLOCK    = 1;
-        enum SIG_SETMASK    = 2;
-    }
-
-    struct siginfo_t
-    {
-        int si_signo;
-        version (MIPS_Any)  // __SI_SWAP_ERRNO_CODE
-        {
-            int si_code;
-            int si_errno;
-        }
-        else
-        {
-            int si_errno;
-            int si_code;
-        }
-        union __si_fields_t
-        {
-            char[128 - 2*int.sizeof - c_long.sizeof] __pad = 0;
-            struct __si_common_t
-            {
-                union __first_t
-                {
-                    struct __piduid_t
-                    {
-                        pid_t si_pid;
-                        uid_t si_uid;
-                    }
-                    __piduid_t __piduid;
-
-                    struct __timer_t
-                    {
-                        int si_timerid;
-                        int si_overrun;
-                    }
-                    __timer_t __timer;
-                }
-                __first_t __first;
-
-                union __second_t
-                {
-                    sigval si_value;
-                    struct __sigchld_t
-                    {
-                        int si_status;
-                        clock_t si_utime;
-                        clock_t si_stime;
-                    }
-                    __sigchld_t __sigchld;
-                }
-                __second_t __second;
-            }
-            __si_common_t __si_common;
-
-            struct __sigfault_t
-            {
-                void *si_addr;
-                short si_addr_lsb;
-                union __first_t
-                {
-                    struct __addr_bnd_t
-                    {
-                        void *si_lower;
-                        void *si_upper;
-                    }
-                    __addr_bnd_t __addr_bnd;
-                    uint si_pkey;
-                }
-                __first_t __first;
-            }
-            __sigfault_t __sigfault;
-
-            struct __sigpoll_t
-            {
-                c_long si_band;
-                int si_fd;
-            }
-            __sigpoll_t __sigpoll;
-
-            struct __sigsys_t
-            {
-                void *si_call_addr;
-                int si_syscall;
-                uint si_arch;
-            }
-            __sigsys_t __sigsys;
-        }
-        __si_fields_t __si_fields;
-    }
-
     int kill(pid_t, int);
     int sigaction(int, const scope sigaction_t*, sigaction_t*);
     int sigaddset(sigset_t*, int);
@@ -1720,235 +1588,6 @@ else version (CRuntime_Musl)
 }
 else version (CRuntime_UClibc)
 {
-    enum SIG_HOLD = cast(sigfn_t2) 2;
-
-    version (MIPS32)
-        private enum _SIGSET_NWORDS = 128 / (8 * c_ulong.sizeof);
-    else
-        private enum _SIGSET_NWORDS = 64 / (8 * c_ulong.sizeof);
-
-    struct sigset_t
-    {
-        c_ulong[_SIGSET_NWORDS] __val;
-    }
-
-    enum SA_NOCLDSTOP   = 1;
-
-    enum SIG_BLOCK      = 0;
-    enum SIG_UNBLOCK    = 1;
-    enum SIG_SETMASK    = 2;
-
-    private enum __SI_MAX_SIZE = 128;
-
-    static if ( __WORDSIZE == 64 )
-    {
-        private enum __SI_PAD_SIZE = ((__SI_MAX_SIZE / int.sizeof) - 4);
-    }
-    else
-    {
-        private enum __SI_PAD_SIZE = ((__SI_MAX_SIZE / int.sizeof) - 3);
-    }
-
-    version (ARM)           version = siginfo_common;
-    else version (X86_64)   version = siginfo_common;
-
-    version (siginfo_common)
-    {
-        struct siginfo_t
-        {
-            int si_signo;       // Signal number
-            int si_errno;       // If non-zero, an errno value associated with
-                                // this signal, as defined in <errno.h>
-            int si_code;        // Signal code
-
-            union _sifields_t
-            {
-                int[__SI_PAD_SIZE] _pad;
-
-                // kill()
-                struct _kill_t
-                {
-                    pid_t si_pid; // Sending process ID
-                    uid_t si_uid; // Real user ID of sending process
-                } _kill_t _kill;
-
-                // POSIX.1b timers.
-                struct _timer_t
-                {
-                    int    si_tid;     // Timer ID
-                    int    si_overrun; // Overrun count
-                    sigval si_sigval;  // Signal value
-                } _timer_t _timer;
-
-                // POSIX.1b signals
-                struct _rt_t
-                {
-                    pid_t  si_pid;    // Sending process ID
-                    uid_t  si_uid;    // Real user ID of sending process
-                    sigval si_sigval; // Signal value
-                } _rt_t _rt;
-
-                // SIGCHLD
-                struct _sigchild_t
-                {
-                    pid_t   si_pid;    // Which child
-                    uid_t   si_uid;    // Real user ID of sending process
-                    int     si_status; // Exit value or signal
-                    clock_t si_utime;
-                    clock_t si_stime;
-                } _sigchild_t _sigchld;
-
-                // SIGILL, SIGFPE, SIGSEGV, SIGBUS
-                struct _sigfault_t
-                {
-                    void*     si_addr;  // Faulting insn/memory ref
-                } _sigfault_t _sigfault;
-
-                // SIGPOLL
-                struct _sigpoll_t
-                {
-                    c_long si_band; // Band event for SIGPOLL;
-                    int      si_fd;
-                } _sigpoll_t _sigpoll;
-
-                // SIGSYS
-                struct _sigsys_t
-                {
-                    void*   _call_addr;   // Calling user insn.
-                    int     _syscall;     // Triggering system call number.
-                    uint    _arch;        // AUDIT_ARCH_* of syscall.
-                } _sigsys_t _sigsys;
-
-            } _sifields_t _sifields;
-
-        nothrow @nogc:
-            @property ref pid_t si_pid()() { return _sifields._kill.si_pid; }
-            @property ref uid_t si_uid()() { return _sifields._kill.si_uid; }
-            @property ref int si_timerid()() { return _sifields._timer.si_tid;}
-            @property ref int si_overrun()() { return _sifields._timer.si_overrun; }
-            @property ref int si_status()() { return _sifields._sigchld.si_status; }
-            @property ref clock_t si_utime()() { return _sifields._sigchld.si_utime; }
-            @property ref clock_t si_stime()() { return _sifields._sigchld.si_stime; }
-            @property ref sigval si_value()() { return _sifields._rt.si_sigval; }
-            @property ref int si_int()() { return _sifields._rt.si_sigval.sival_int; }
-            @property ref void* si_ptr()() { return _sifields._rt.si_sigval.sival_ptr; }
-            @property ref void* si_addr()() { return _sifields._sigfault.si_addr; }
-            @property ref c_long si_band()() { return _sifields._sigpoll.si_band; }
-            @property ref int  si_fd()() { return _sifields._sigpoll.si_fd; }
-            @property ref void*  si_call_addr()() { return _sifields._sigsys._call_addr; }
-            @property ref int  si_syscall()() { return _sifields._sigsys._syscall; }
-            @property ref uint  si_arch()() { return _sifields._sigsys._arch; }
-        }
-    }
-    else version (MIPS32)
-    {
-        struct siginfo_t
-        {
-            int si_signo;       // Signal number
-            int si_errno;       // If non-zero, an errno value associated with
-                                // this signal, as defined in <errno.h>
-            int si_code;        // Signal code
-
-            int[__SI_MAX_SIZE / int.sizeof - __SI_PAD_SIZE - 3] __pad0;
-
-            union _sifields_t
-            {
-                int[__SI_PAD_SIZE] _pad;
-
-                // kill()
-                struct _kill_t
-                {
-                    pid_t si_pid; // Sending process ID
-                    uid_t si_uid; // Real user ID of sending process
-                } _kill_t _kill;
-
-                // POSIX.1b timers.
-                struct _timer_t
-                {
-                    int    si_tid;     // Timer ID
-                    int    si_overrun; // Overrun count
-                    sigval si_sigval;  // Signal value
-                } _timer_t _timer;
-
-                // POSIX.1b signals
-                struct _rt_t
-                {
-                    pid_t  si_pid;    // Sending process ID
-                    uid_t  si_uid;    // Real user ID of sending process
-                    sigval si_sigval; // Signal value
-                } _rt_t _rt;
-
-                // SIGCHLD
-                struct _sigchild_t
-                {
-                    pid_t   si_pid;    // Which child
-                    uid_t   si_uid;    // Real user ID of sending process
-                    int     si_status; // Exit value or signal
-                    clock_t si_utime;
-                    clock_t si_stime;
-                } _sigchild_t _sigchld;
-
-                // SIGILL, SIGFPE, SIGSEGV, SIGBUS
-                struct _sigfault_t
-                {
-                    void*   si_addr;  // Faulting insn/memory ref
-                    short   si_addr_lsb;
-                } _sigfault_t _sigfault;
-
-                // SIGPOLL
-                struct _sigpoll_t
-                {
-                    c_long si_band; // Band event for SIGPOLL;
-                    int      si_fd;
-                } _sigpoll_t _sigpoll;
-
-                // SIGSYS
-                struct _sigsys_t
-                {
-                    void*   _call_addr;   // Calling user insn.
-                    int     _syscall;     // Triggering system call number.
-                    uint    _arch;        // AUDIT_ARCH_* of syscall.
-                } _sigsys_t _sigsys;
-
-            } _sifields_t _sifields;
-
-        nothrow @nogc:
-            @property ref pid_t si_pid()() { return _sifields._kill.si_pid; }
-            @property ref uid_t si_uid()() { return _sifields._kill.si_uid; }
-            @property ref int si_timerid()() { return _sifields._timer.si_tid;}
-            @property ref int si_overrun()() { return _sifields._timer.si_overrun; }
-            @property ref int si_status()() { return _sifields._sigchld.si_status; }
-            @property ref clock_t si_utime()() { return _sifields._sigchld.si_utime; }
-            @property ref clock_t si_stime()() { return _sifields._sigchld.si_stime; }
-            @property ref sigval si_value()() { return _sifields._rt.si_sigval; }
-            @property ref int si_int()() { return _sifields._rt.si_sigval.sival_int; }
-            @property ref void* si_ptr()() { return _sifields._rt.si_sigval.sival_ptr; }
-            @property ref void* si_addr()() { return _sifields._sigfault.si_addr; }
-            @property ref c_long si_band()() { return _sifields._sigpoll.si_band; }
-            @property ref int  si_fd()() { return _sifields._sigpoll.si_fd; }
-            @property ref void*  si_call_addr()() { return _sifields._sigsys._call_addr; }
-            @property ref int  si_syscall()() { return _sifields._sigsys._syscall; }
-            @property ref uint  si_arch()() { return _sifields._sigsys._arch; }
-        }
-    }
-    else
-    {
-        static assert(false, "Architecture not supported.");
-    }
-
-    enum
-    {
-        SI_ASYNCNL = -60,
-        SI_TKILL   = -6,
-        SI_SIGIO,
-        SI_ASYNCIO,
-        SI_MESGQ,
-        SI_TIMER,
-        SI_QUEUE,
-        SI_USER,
-        SI_KERNEL  = 0x80
-    }
-
     int kill(pid_t, int);
     int sigaction(int, const scope sigaction_t*, sigaction_t*);
     int sigaddset(sigset_t*, int);
@@ -1985,26 +1624,6 @@ SA_RESTART
 SA_SIGINFO
 SA_NOCLDWAIT
 SA_NODEFER
-SS_ONSTACK
-SS_DISABLE
-MINSIGSTKSZ
-SIGSTKSZ
-
-ucontext_t // from ucontext
-mcontext_t // from ucontext
-
-struct stack_t
-{
-    void*   ss_sp;
-    size_t  ss_size;
-    int     ss_flags;
-}
-
-struct sigstack
-{
-    int   ss_onstack;
-    void* ss_sp;
-}
 
 ILL_ILLOPC
 ILL_ILLOPN
@@ -2047,20 +1666,9 @@ POLL_MSG
 POLL_ERR
 POLL_PRI
 POLL_HUP
-
-sigfn_t bsd_signal(int sig, sigfn_t func);
-sigfn_t sigset(int sig, sigfn_t func);
-
-int killpg(pid_t, int);
-int sigaltstack(const scope stack_t*, stack_t*);
-int sighold(int);
-int sigignore(int);
-int siginterrupt(int, int);
-int sigpause(int);
-int sigrelse(int);
 */
 
-version (CRuntime_Glibc)
+version (linux)
 {
     version (X86_Any)
     {
@@ -2145,33 +1753,29 @@ version (CRuntime_Glibc)
     else
         static assert(0, "unimplemented");
 
-    enum SA_ONSTACK     = 0x08000000;
-    enum SA_RESETHAND   = 0x80000000;
-    enum SA_RESTART     = 0x10000000;
-    enum SA_SIGINFO     = 4;
-    enum SA_NOCLDWAIT   = 2;
-    enum SA_NODEFER     = 0x40000000;
-    enum SS_ONSTACK     = 1;
-    enum SS_DISABLE     = 2;
-    enum MINSIGSTKSZ    = 2048;
-    enum SIGSTKSZ       = 8192;
-
-    //ucontext_t (defined in core.sys.posix.ucontext)
-    //mcontext_t (defined in core.sys.posix.ucontext)
-
-    struct stack_t
+    version (MIPS_Any)
     {
-        void*   ss_sp;
-        int     ss_flags;
-        size_t  ss_size;
+        enum SA_ONSTACK   = 0x08000000;
+        enum SA_RESETHAND = 0x80000000;
+        enum SA_RESTART   = 0x10000000;
+        enum SA_SIGINFO   = 8;
+        enum SA_NOCLDWAIT = 0x10000;
+        enum SA_NODEFER   = 0x40000000;
     }
-
-    struct sigstack
+    else
     {
-        void*   ss_sp;
-        int     ss_onstack;
+        enum SA_ONSTACK   = 0x08000000;
+        enum SA_RESETHAND = 0x80000000;
+        enum SA_RESTART   = 0x10000000;
+        enum SA_SIGINFO   = 4;
+        enum SA_NOCLDWAIT = 2;
+        enum SA_NODEFER   = 0x40000000;
     }
 
+    enum SA_NOMASK      = SA_NODEFER;
+    enum SA_ONESHOT     = SA_RESETHAND;
+    enum SA_STACK       = SA_ONSTACK;
+
     enum
     {
         ILL_ILLOPC = 1,
@@ -2234,22 +1838,6 @@ version (CRuntime_Glibc)
         POLL_PRI,
         POLL_HUP
     }
-
-    sigfn_t bsd_signal(int sig, sigfn_t func);
-    sigfn_t sigset(int sig, sigfn_t func);
-
-  nothrow:
-  @nogc:
-    sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
-    sigfn_t2 sigset(int sig, sigfn_t2 func);
-
-    int killpg(pid_t, int);
-    int sigaltstack(const scope stack_t*, stack_t*);
-    int sighold(int);
-    int sigignore(int);
-    int siginterrupt(int, int);
-    int sigpause(int);
-    int sigrelse(int);
 }
 else version (Darwin)
 {
@@ -2267,26 +1855,6 @@ else version (Darwin)
     enum SA_SIGINFO     = 0x0040;
     enum SA_NOCLDWAIT   = 0x0020;
     enum SA_NODEFER     = 0x0010;
-    enum SS_ONSTACK     = 0x0001;
-    enum SS_DISABLE     = 0x0004;
-    enum MINSIGSTKSZ    = 32768;
-    enum SIGSTKSZ       = 131072;
-
-    //ucontext_t (defined in core.sys.posix.ucontext)
-    //mcontext_t (defined in core.sys.posix.ucontext)
-
-    struct stack_t
-    {
-        void*   ss_sp;
-        size_t  ss_size;
-        int     ss_flags;
-    }
-
-    struct sigstack
-    {
-        void*   ss_sp;
-        int     ss_onstack;
-    }
 
     enum ILL_ILLOPC = 1;
     enum ILL_ILLOPN = 4;
@@ -2344,32 +1912,16 @@ else version (Darwin)
         POLL_PRI,
         POLL_HUP
     }
-
-    sigfn_t bsd_signal(int sig, sigfn_t func);
-    sigfn_t sigset(int sig, sigfn_t func);
-
-  nothrow:
-  @nogc:
-    sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
-    sigfn_t2 sigset(int sig, sigfn_t2 func);
-
-    int killpg(pid_t, int);
-    int sigaltstack(const scope stack_t*, stack_t*);
-    int sighold(int);
-    int sigignore(int);
-    int siginterrupt(int, int);
-    int sigpause(int);
-    int sigrelse(int);
-}
-else version (FreeBSD)
-{
-    // No SIGPOLL on *BSD
-    enum SIGPROF        = 27;
-    enum SIGSYS         = 12;
-    enum SIGTRAP        = 5;
-    enum SIGVTALRM      = 26;
-    enum SIGXCPU        = 24;
-    enum SIGXFSZ        = 25;
+}
+else version (FreeBSD)
+{
+    // No SIGPOLL on *BSD
+    enum SIGPROF        = 27;
+    enum SIGSYS         = 12;
+    enum SIGTRAP        = 5;
+    enum SIGVTALRM      = 26;
+    enum SIGXCPU        = 24;
+    enum SIGXFSZ        = 25;
 
     enum
     {
@@ -2381,31 +1933,6 @@ else version (FreeBSD)
         SA_SIGINFO      = 0x0040,
     }
 
-    enum
-    {
-        SS_ONSTACK = 0x0001,
-        SS_DISABLE = 0x0004,
-    }
-
-    enum MINSIGSTKSZ = 512 * 4;
-    enum SIGSTKSZ    = (MINSIGSTKSZ + 32768);
-
-    //ucontext_t (defined in core.sys.posix.ucontext)
-    //mcontext_t (defined in core.sys.posix.ucontext)
-
-    struct stack_t
-    {
-        void*   ss_sp;
-        size_t  ss_size;
-        int     ss_flags;
-    }
-
-    struct sigstack
-    {
-        void*   ss_sp;
-        int     ss_onstack;
-    }
-
     enum
     {
         ILL_ILLOPC = 1,
@@ -2468,22 +1995,6 @@ else version (FreeBSD)
         POLL_PRI,
         POLL_HUP,
     }
-
-    //sigfn_t bsd_signal(int sig, sigfn_t func);
-    sigfn_t sigset(int sig, sigfn_t func);
-
-  nothrow:
-  @nogc:
-    //sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
-    sigfn_t2 sigset(int sig, sigfn_t2 func);
-
-    int killpg(pid_t, int);
-    int sigaltstack(const scope stack_t*, stack_t*);
-    int sighold(int);
-    int sigignore(int);
-    int siginterrupt(int, int);
-    int sigpause(int);
-    int sigrelse(int);
 }
 else version (NetBSD)
 {
@@ -2505,31 +2016,6 @@ else version (NetBSD)
         SA_SIGINFO      = 0x0040,
     }
 
-    enum
-    {
-        SS_ONSTACK = 0x0001,
-        SS_DISABLE = 0x0004,
-    }
-
-    enum MINSIGSTKSZ = 8192;
-    enum SIGSTKSZ    = (MINSIGSTKSZ + 32768);
-
-    //ucontext_t (defined in core.sys.posix.ucontext)
-    //mcontext_t (defined in core.sys.posix.ucontext)
-
-    struct stack_t
-    {
-        void*   ss_sp;
-        size_t  ss_size;
-        int     ss_flags;
-    }
-
-    struct sigstack
-    {
-        void*   ss_sp;
-        int     ss_onstack;
-    }
-
     enum
     {
         ILL_ILLOPC = 1,
@@ -2592,22 +2078,6 @@ else version (NetBSD)
         POLL_PRI,
         POLL_HUP,
     }
-
-    //sigfn_t bsd_signal(int sig, sigfn_t func);
-    sigfn_t sigset(int sig, sigfn_t func);
-
-  nothrow:
-  @nogc:
-    //sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
-    sigfn_t2 sigset(int sig, sigfn_t2 func);
-
-    int killpg(pid_t, int);
-    int sigaltstack(const scope stack_t*, stack_t*);
-    int sighold(int);
-    int sigignore(int);
-    int siginterrupt(int, int);
-    int sigpause(int);
-    int sigrelse(int);
 }
 else version (OpenBSD)
 {
@@ -2629,25 +2099,6 @@ else version (OpenBSD)
         SA_SIGINFO      = 0x0040,
     }
 
-    enum
-    {
-        SS_ONSTACK = 0x0001,
-        SS_DISABLE = 0x0004,
-    }
-
-    enum MINSIGSTKSZ = 8192;
-    enum SIGSTKSZ    = (MINSIGSTKSZ + 32768);
-
-    //ucontext_t (defined in core.sys.posix.ucontext)
-    //mcontext_t (defined in core.sys.posix.ucontext)
-
-    struct stack_t
-    {
-        void*   ss_sp;
-        size_t  ss_size;
-        int     ss_flags;
-    }
-
     enum
     {
         ILL_ILLOPC = 1,
@@ -2717,13 +2168,6 @@ else version (OpenBSD)
         POLL_HUP,
         NSIGPOLL = POLL_HUP,
     }
-
-  nothrow:
-  @nogc:
-    int killpg(pid_t, int);
-    int sigaltstack(const scope stack_t*, stack_t*);
-    int siginterrupt(int, int);
-    int sigpause(int);
 }
 else version (DragonFlyBSD)
 {
@@ -2745,31 +2189,6 @@ else version (DragonFlyBSD)
         SA_SIGINFO      = 0x0040,
     }
 
-    enum
-    {
-        SS_ONSTACK = 0x0001,
-        SS_DISABLE = 0x0004,
-    }
-
-    enum MINSIGSTKSZ = 8192;
-    enum SIGSTKSZ    = (MINSIGSTKSZ + 32768);
-
-    //ucontext_t (defined in core.sys.posix.ucontext)
-    //mcontext_t (defined in core.sys.posix.ucontext)
-
-    struct stack_t
-    {
-        void*   ss_sp;
-        size_t  ss_size;
-        int     ss_flags;
-    }
-
-    struct sigstack
-    {
-        void*   ss_sp;
-        int     ss_onstack;
-    }
-
     enum
     {
         ILL_ILLOPC = 1,
@@ -2832,26 +2251,11 @@ else version (DragonFlyBSD)
         POLL_PRI,
         POLL_HUP,
     }
-
-    //sigfn_t bsd_signal(int sig, sigfn_t func);
-    sigfn_t sigset(int sig, sigfn_t func);
-
-  nothrow:
-  @nogc:
-    //sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
-    sigfn_t2 sigset(int sig, sigfn_t2 func);
-
-    int killpg(pid_t, int);
-    int sigaltstack(const scope stack_t*, stack_t*);
-    int sighold(int);
-    int sigignore(int);
-    int siginterrupt(int, int);
-    int sigpause(int);
-    int sigrelse(int);
 }
 else version (Solaris)
 {
     enum SIGPOLL = 22;
+    enum SIGIO = SIGPOLL;
     enum SIGPROF = 29;
     enum SIGSYS = 12;
     enum SIGTRAP = 5;
@@ -2869,28 +2273,6 @@ else version (Solaris)
         SA_SIGINFO = 0x00008,
     }
 
-    enum
-    {
-        SS_ONSTACK = 0x0001,
-        SS_DISABLE = 0x0002,
-    }
-
-    enum MINSIGSTKSZ = 2048;
-    enum SIGSTKSZ = 8192;
-
-    struct stack_t
-    {
-        void* ss_sp;
-        size_t ss_size;
-        int ss_flags;
-    }
-
-    struct sigstack
-    {
-        void* ss_sp;
-        int ss_onstack;
-    }
-
     enum
     {
         ILL_ILLOPC = 1,
@@ -2958,11 +2340,75 @@ else version (Solaris)
         POLL_PRI,
         POLL_HUP,
     }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+/*
+SS_ONSTACK
+SS_DISABLE
+MINSIGSTKSZ
+SIGSTKSZ
+
+ucontext_t // from ucontext
+mcontext_t // from ucontext
+
+struct stack_t
+{
+    void*   ss_sp;
+    size_t  ss_size;
+    int     ss_flags;
+}
+
+struct sigstack
+{
+    int   ss_onstack;
+    void* ss_sp;
+}
+
+sigfn_t bsd_signal(int sig, sigfn_t func);
+sigfn_t sigset(int sig, sigfn_t func);
+
+int killpg(pid_t, int);
+int sigaltstack(const scope stack_t*, stack_t*);
+int sighold(int);
+int sigignore(int);
+int siginterrupt(int, int);
+int sigpause(int);
+int sigrelse(int);
+*/
+
+version (CRuntime_Glibc)
+{
+    enum SS_ONSTACK     = 1;
+    enum SS_DISABLE     = 2;
+    enum MINSIGSTKSZ    = 2048;
+    enum SIGSTKSZ       = 8192;
+
+    //ucontext_t (defined in core.sys.posix.ucontext)
+    //mcontext_t (defined in core.sys.posix.ucontext)
+
+    struct stack_t
+    {
+        void*   ss_sp;
+        int     ss_flags;
+        size_t  ss_size;
+    }
+
+    struct sigstack
+    {
+        void*   ss_sp;
+        int     ss_onstack;
+    }
 
+    sigfn_t bsd_signal(int sig, sigfn_t func);
     sigfn_t sigset(int sig, sigfn_t func);
 
   nothrow:
   @nogc:
+    sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
     sigfn_t2 sigset(int sig, sigfn_t2 func);
 
     int killpg(pid_t, int);
@@ -2973,95 +2419,252 @@ else version (Solaris)
     int sigpause(int);
     int sigrelse(int);
 }
-else version (CRuntime_Bionic)
+else version (Darwin)
 {
-    enum SIGPOLL   = 29;
-    enum SIGPROF   = 27;
-    enum SIGSYS    = 31;
-    enum SIGTRAP   = 5;
-    enum SIGVTALRM = 26;
-    enum SIGXCPU   = 24;
-    enum SIGXFSZ   = 25;
-
-    enum SA_ONSTACK     = 0x08000000;
-    enum SA_RESETHAND   = 0x80000000;
-    enum SA_RESTART     = 0x10000000;
-    enum SA_SIGINFO     = 4;
-    enum SA_NOCLDWAIT   = 2;
-    enum SA_NODEFER     = 0x40000000;
-    enum SS_ONSTACK     = 1;
-    enum SS_DISABLE     = 2;
-    enum MINSIGSTKSZ    = 2048;
-    enum SIGSTKSZ       = 8192;
+    enum SS_ONSTACK     = 0x0001;
+    enum SS_DISABLE     = 0x0004;
+    enum MINSIGSTKSZ    = 32768;
+    enum SIGSTKSZ       = 131072;
+
+    //ucontext_t (defined in core.sys.posix.ucontext)
+    //mcontext_t (defined in core.sys.posix.ucontext)
 
     struct stack_t
     {
         void*   ss_sp;
-        int     ss_flags;
         size_t  ss_size;
+        int     ss_flags;
     }
 
-    enum
+    struct sigstack
     {
-        ILL_ILLOPC = 1,
-        ILL_ILLOPN,
-        ILL_ILLADR,
-        ILL_ILLTRP,
-        ILL_PRVOPC,
-        ILL_PRVREG,
-        ILL_COPROC,
-        ILL_BADSTK
+        void*   ss_sp;
+        int     ss_onstack;
     }
 
+    sigfn_t bsd_signal(int sig, sigfn_t func);
+    sigfn_t sigset(int sig, sigfn_t func);
+
+  nothrow:
+  @nogc:
+    sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
+    sigfn_t2 sigset(int sig, sigfn_t2 func);
+
+    int killpg(pid_t, int);
+    int sigaltstack(const scope stack_t*, stack_t*);
+    int sighold(int);
+    int sigignore(int);
+    int siginterrupt(int, int);
+    int sigpause(int);
+    int sigrelse(int);
+}
+else version (FreeBSD)
+{
     enum
     {
-        FPE_INTDIV = 1,
-        FPE_INTOVF,
-        FPE_FLTDIV,
-        FPE_FLTOVF,
-        FPE_FLTUND,
-        FPE_FLTRES,
-        FPE_FLTINV,
-        FPE_FLTSUB
+        SS_ONSTACK = 0x0001,
+        SS_DISABLE = 0x0004,
     }
 
+    enum MINSIGSTKSZ = 512 * 4;
+    enum SIGSTKSZ    = (MINSIGSTKSZ + 32768);
+
+    //ucontext_t (defined in core.sys.posix.ucontext)
+    //mcontext_t (defined in core.sys.posix.ucontext)
+
+    struct stack_t
+    {
+        void*   ss_sp;
+        size_t  ss_size;
+        int     ss_flags;
+    }
+
+    struct sigstack
+    {
+        void*   ss_sp;
+        int     ss_onstack;
+    }
+
+    //sigfn_t bsd_signal(int sig, sigfn_t func);
+    sigfn_t sigset(int sig, sigfn_t func);
+
+  nothrow:
+  @nogc:
+    //sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
+    sigfn_t2 sigset(int sig, sigfn_t2 func);
+
+    int killpg(pid_t, int);
+    int sigaltstack(const scope stack_t*, stack_t*);
+    int sighold(int);
+    int sigignore(int);
+    int siginterrupt(int, int);
+    int sigpause(int);
+    int sigrelse(int);
+}
+else version (NetBSD)
+{
     enum
     {
-        SEGV_MAPERR = 1,
-        SEGV_ACCERR
+        SS_ONSTACK = 0x0001,
+        SS_DISABLE = 0x0004,
     }
 
+    enum MINSIGSTKSZ = 8192;
+    enum SIGSTKSZ    = (MINSIGSTKSZ + 32768);
+
+    //ucontext_t (defined in core.sys.posix.ucontext)
+    //mcontext_t (defined in core.sys.posix.ucontext)
+
+    struct stack_t
+    {
+        void*   ss_sp;
+        size_t  ss_size;
+        int     ss_flags;
+    }
+
+    struct sigstack
+    {
+        void*   ss_sp;
+        int     ss_onstack;
+    }
+
+    //sigfn_t bsd_signal(int sig, sigfn_t func);
+    sigfn_t sigset(int sig, sigfn_t func);
+
+  nothrow:
+  @nogc:
+    //sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
+    sigfn_t2 sigset(int sig, sigfn_t2 func);
+
+    int killpg(pid_t, int);
+    int sigaltstack(const scope stack_t*, stack_t*);
+    int sighold(int);
+    int sigignore(int);
+    int siginterrupt(int, int);
+    int sigpause(int);
+    int sigrelse(int);
+}
+else version (OpenBSD)
+{
     enum
     {
-        BUS_ADRALN = 1,
-        BUS_ADRERR,
-        BUS_OBJERR
+        SS_ONSTACK = 0x0001,
+        SS_DISABLE = 0x0004,
     }
 
+    enum MINSIGSTKSZ = 8192;
+    enum SIGSTKSZ    = (MINSIGSTKSZ + 32768);
+
+    //ucontext_t (defined in core.sys.posix.ucontext)
+    //mcontext_t (defined in core.sys.posix.ucontext)
+
+    struct stack_t
+    {
+        void*   ss_sp;
+        size_t  ss_size;
+        int     ss_flags;
+    }
+
+  nothrow:
+  @nogc:
+    int killpg(pid_t, int);
+    int sigaltstack(const scope stack_t*, stack_t*);
+    int siginterrupt(int, int);
+    int sigpause(int);
+}
+else version (DragonFlyBSD)
+{
     enum
     {
-        TRAP_BRKPT = 1,
-        TRAP_TRACE
+        SS_ONSTACK = 0x0001,
+        SS_DISABLE = 0x0004,
     }
 
+    enum MINSIGSTKSZ = 8192;
+    enum SIGSTKSZ    = (MINSIGSTKSZ + 32768);
+
+    //ucontext_t (defined in core.sys.posix.ucontext)
+    //mcontext_t (defined in core.sys.posix.ucontext)
+
+    struct stack_t
+    {
+        void*   ss_sp;
+        size_t  ss_size;
+        int     ss_flags;
+    }
+
+    struct sigstack
+    {
+        void*   ss_sp;
+        int     ss_onstack;
+    }
+
+    //sigfn_t bsd_signal(int sig, sigfn_t func);
+    sigfn_t sigset(int sig, sigfn_t func);
+
+  nothrow:
+  @nogc:
+    //sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
+    sigfn_t2 sigset(int sig, sigfn_t2 func);
+
+    int killpg(pid_t, int);
+    int sigaltstack(const scope stack_t*, stack_t*);
+    int sighold(int);
+    int sigignore(int);
+    int siginterrupt(int, int);
+    int sigpause(int);
+    int sigrelse(int);
+}
+else version (Solaris)
+{
     enum
     {
-        CLD_EXITED = 1,
-        CLD_KILLED,
-        CLD_DUMPED,
-        CLD_TRAPPED,
-        CLD_STOPPED,
-        CLD_CONTINUED
+        SS_ONSTACK = 0x0001,
+        SS_DISABLE = 0x0002,
+    }
+
+    enum MINSIGSTKSZ = 2048;
+    enum SIGSTKSZ = 8192;
+
+    struct stack_t
+    {
+        void* ss_sp;
+        size_t ss_size;
+        int ss_flags;
+    }
+
+    struct sigstack
+    {
+        void* ss_sp;
+        int ss_onstack;
     }
 
-    enum
+    sigfn_t sigset(int sig, sigfn_t func);
+
+  nothrow:
+  @nogc:
+    sigfn_t2 sigset(int sig, sigfn_t2 func);
+
+    int killpg(pid_t, int);
+    int sigaltstack(const scope stack_t*, stack_t*);
+    int sighold(int);
+    int sigignore(int);
+    int siginterrupt(int, int);
+    int sigpause(int);
+    int sigrelse(int);
+}
+else version (CRuntime_Bionic)
+{
+    enum SS_ONSTACK     = 1;
+    enum SS_DISABLE     = 2;
+    enum MINSIGSTKSZ    = 2048;
+    enum SIGSTKSZ       = 8192;
+
+    struct stack_t
     {
-        POLL_IN = 1,
-        POLL_OUT,
-        POLL_MSG,
-        POLL_ERR,
-        POLL_PRI,
-        POLL_HUP
+        void*   ss_sp;
+        int     ss_flags;
+        size_t  ss_size;
     }
 
     sigfn_t bsd_signal(int, sigfn_t);
@@ -3076,41 +2679,6 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
-    version (MIPS_Any)
-    {
-        enum SIGPOLL   = 22;
-        enum SIGPROF   = 29;
-        enum SIGSYS    = 12;
-        enum SIGTRAP   = 5;
-        enum SIGVTALRM = 28;
-        enum SIGXCPU   = 30;
-        enum SIGXFSZ   = 31;
-
-        enum SA_ONSTACK   = 0x08000000;
-        enum SA_RESETHAND = 0x80000000;
-        enum SA_RESTART   = 0x10000000;
-        enum SA_SIGINFO   = 8;
-        enum SA_NOCLDWAIT = 0x10000;
-        enum SA_NODEFER   = 0x40000000;
-    }
-    else
-    {
-        enum SIGPOLL   = 29;
-        enum SIGPROF   = 27;
-        enum SIGSYS    = 31;
-        enum SIGTRAP   = 5;
-        enum SIGVTALRM = 26;
-        enum SIGXCPU   = 24;
-        enum SIGXFSZ   = 25;
-
-        enum SA_ONSTACK   = 0x08000000;
-        enum SA_RESETHAND = 0x80000000;
-        enum SA_RESTART   = 0x10000000;
-        enum SA_SIGINFO   = 4;
-        enum SA_NOCLDWAIT = 2;
-        enum SA_NODEFER   = 0x40000000;
-    }
-
     enum SS_ONSTACK = 1;
     enum SS_DISABLE = 2;
 
@@ -3169,69 +2737,6 @@ else version (CRuntime_Musl)
         }
     }
 
-    enum
-    {
-        ILL_ILLOPC = 1,
-        ILL_ILLOPN,
-        ILL_ILLADR,
-        ILL_ILLTRP,
-        ILL_PRVOPC,
-        ILL_PRVREG,
-        ILL_COPROC,
-        ILL_BADSTK
-    }
-
-    enum
-    {
-        FPE_INTDIV = 1,
-        FPE_INTOVF,
-        FPE_FLTDIV,
-        FPE_FLTOVF,
-        FPE_FLTUND,
-        FPE_FLTRES,
-        FPE_FLTINV,
-        FPE_FLTSUB
-    }
-
-    enum
-    {
-        SEGV_MAPERR = 1,
-        SEGV_ACCERR
-    }
-
-    enum
-    {
-        BUS_ADRALN = 1,
-        BUS_ADRERR,
-        BUS_OBJERR
-    }
-
-    enum
-    {
-        TRAP_BRKPT = 1,
-        TRAP_TRACE
-    }
-
-    enum
-    {
-        CLD_EXITED = 1,
-        CLD_KILLED,
-        CLD_DUMPED,
-        CLD_TRAPPED,
-        CLD_STOPPED,
-        CLD_CONTINUED
-    }
-
-    enum
-    {
-        POLL_IN = 1,
-        POLL_OUT,
-        POLL_MSG,
-        POLL_ERR,
-        POLL_PRI,
-        POLL_HUP
-    }
-
     sigfn_t bsd_signal(int sig, sigfn_t func);
     sigfn_t sigset(int sig, sigfn_t func);
 
@@ -3250,77 +2755,11 @@ else version (CRuntime_Musl)
 }
 else version (CRuntime_UClibc)
 {
-    version (X86_64)
-    {
-        enum SIGTRAP         = 5;
-        enum SIGIOT          = 6;
-        enum SIGSTKFLT       = 16;
-        enum SIGCLD          = SIGCHLD;
-        enum SIGXCPU         = 24;
-        enum SIGXFSZ         = 25;
-        enum SIGVTALRM       = 26;
-        enum SIGPROF         = 27;
-        enum SIGWINCH        = 28;
-        enum SIGPOLL         = SIGIO;
-        enum SIGIO           = 29;
-        enum SIGPWR          = 30;
-        enum SIGSYS          = 31;
-        enum SIGUNUSED       = 31;
-    }
-    else version (MIPS32)
-    {
-        enum SIGTRAP = 5;
-        enum SIGIOT           = 6;
-        enum SIGEMT           = 7;
-        enum SIGFPE           = 8;
-        enum SIGSYS           = 12;
-        enum SIGCLD           = SIGCHLD;
-        enum SIGPWR           = 19;
-        enum SIGWINCH         = 20;
-        enum SIGIO            = 22;
-        enum SIGPOLL          = SIGIO;
-        enum SIGVTALRM        = 28;
-        enum SIGPROF          = 29;
-        enum SIGXCPU          = 30;
-        enum SIGXFSZ          = 31;
-    }
-    else version (ARM)
-    {
-        enum SIGTRAP = 5;
-        enum SIGIOT = 6;
-        enum SIGSTKFLT = 16;
-        enum SIGCLD = SIGCHLD;
-        enum SIGXCPU = 24;
-        enum SIGXFSZ = 25;
-        enum SIGVTALRM = 26;
-        enum SIGPROF = 27;
-        enum SIGWINCH = 28;
-        enum SIGPOLL = SIGIO;
-        enum SIGIO = 29;
-        enum SIGPWR = 30;
-        enum SIGSYS = 31;
-        enum SIGUNUSED = 31;
-    }
-    else
-        static assert(0, "unimplemented");
-
-    enum SA_ONSTACK     = 0x08000000;
-    enum SA_RESETHAND   = 0x80000000;
-    enum SA_RESTART     = 0x10000000;
-    enum SA_SIGINFO     = 4;
-    enum SA_NOCLDWAIT   = 2;
-    enum SA_NODEFER     = 0x40000000;
     enum SS_ONSTACK     = 1;
     enum SS_DISABLE     = 2;
     enum MINSIGSTKSZ    = 2048;
     enum SIGSTKSZ       = 8192;
 
-    enum SA_INTERRUPT   = 0x20000000;
-
-    enum SA_NOMASK      = SA_NODEFER;
-    enum SA_ONESHOT     = SA_RESETHAND;
-    enum SA_STACK       = SA_ONSTACK;
-
     version (MIPS32)
     {
         struct stack_t
@@ -3346,76 +2785,6 @@ else version (CRuntime_UClibc)
         int     ss_onstack;
     }
 
-    // `si_code' values for SIGILL signal.
-    enum
-    {
-      ILL_ILLOPC = 1,       // Illegal opcode.
-      ILL_ILLOPN,           // Illegal operand.
-      ILL_ILLADR,           // Illegal addressing mode.
-      ILL_ILLTRP,           // Illegal trap.
-      ILL_PRVOPC,           // Privileged opcode.
-      ILL_PRVREG,           // Privileged register.
-      ILL_COPROC,           // Coprocessor error.
-      ILL_BADSTK            // Internal stack error.
-    }
-
-    // `si_code' values for SIGFPE signal.
-    enum
-    {
-      FPE_INTDIV = 1,       // Integer divide by zero.
-      FPE_INTOVF,           // Integer overflow.
-      FPE_FLTDIV,           // Floating point divide by zero.
-      FPE_FLTOVF,           // Floating point overflow.
-      FPE_FLTUND,           // Floating point underflow.
-      FPE_FLTRES,           // Floating point inexact result.
-      FPE_FLTINV,           // Floating point invalid operation.
-      FPE_FLTSUB            // Subscript out of range.
-    }
-
-    // `si_code' values for SIGSEGV signal.
-    enum
-    {
-      SEGV_MAPERR = 1,      // Address not mapped to object.
-      SEGV_ACCERR           // Invalid permissions for mapped object.
-    }
-
-    // `si_code' values for SIGBUS signal.
-    enum
-    {
-      BUS_ADRALN = 1,       // Invalid address alignment.
-      BUS_ADRERR,           // Non-existant physical address.
-      BUS_OBJERR            // Object specific hardware error.
-    }
-
-    // `si_code' values for SIGTRAP signal.
-    enum
-    {
-      TRAP_BRKPT = 1,       // Process breakpoint.
-      TRAP_TRACE            // Process trace trap.
-    }
-
-    // `si_code' values for SIGCHLD signal.
-    enum
-    {
-      CLD_EXITED = 1,       // Child has exited.
-      CLD_KILLED,           // Child was killed.
-      CLD_DUMPED,           // Child terminated abnormally.
-      CLD_TRAPPED,          // Traced child has trapped.
-      CLD_STOPPED,          // Child has stopped.
-      CLD_CONTINUED         // Stopped child has continued.
-    }
-
-    // `si_code' values for SIGPOLL signal.
-    enum
-    {
-      POLL_IN = 1,          // Data input available.
-      POLL_OUT,         // Output buffers available.
-      POLL_MSG,         // Input message available.
-      POLL_ERR,         // I/O error.
-      POLL_PRI,         // High priority input available.
-      POLL_HUP          // Device disconnected.
-    }
-
     sigfn_t sigset(int sig, sigfn_t func);
 
   nothrow:
@@ -3524,16 +2893,12 @@ struct sigevent
     void(*)(sigval) sigev_notify_function;
     pthread_attr_t* sigev_notify_attributes;
 }
-
-int sigqueue(pid_t, int, const sigval);
-int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
-int sigwaitinfo(const scope sigset_t*, siginfo_t*);
 */
 
 nothrow:
 @nogc:
 
-version (CRuntime_Glibc)
+version (linux)
 {
     private enum __SIGEV_MAX_SIZE = 64;
 
@@ -3552,22 +2917,18 @@ version (CRuntime_Glibc)
         int         sigev_signo;
         int         sigev_notify;
 
-        union _sigev_un_t
+        union
         {
             int[__SIGEV_PAD_SIZE] _pad;
             pid_t                 _tid;
 
-            struct _sigev_thread_t
+            struct
             {
-                void function(sigval)   _function;
-                void*                   _attribute;
-            } _sigev_thread_t _sigev_thread;
-        } _sigev_un_t _sigev_un;
+                void function(sigval) sigev_notify_function;
+                void*                 sigev_notify_attributes;
+            }
+        }
     }
-
-    int sigqueue(pid_t, int, const sigval);
-    int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
-    int sigwaitinfo(const scope sigset_t*, siginfo_t*);
 }
 else version (FreeBSD)
 {
@@ -3576,21 +2937,17 @@ else version (FreeBSD)
         int             sigev_notify;
         int             sigev_signo;
         sigval          sigev_value;
-        union  _sigev_un
+        union
         {
             lwpid_t _threadid;
-            struct _sigev_thread
+            struct
             {
-                void function(sigval) _function;
-                void* _attribute;
+                void function(sigval) sigev_notify_function;
+                void* sigev_notify_attributes;
             }
             c_long[8] __spare__;
         }
     }
-
-    int sigqueue(pid_t, int, const sigval);
-    int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
-    int sigwaitinfo(const scope sigset_t*, siginfo_t*);
 }
 else version (NetBSD)
 {
@@ -3602,10 +2959,6 @@ else version (NetBSD)
         void function(sigval) sigev_notify_function;
         void /* pthread_attr_t */*sigev_notify_attributes;
     }
-
-    int sigqueue(pid_t, int, const sigval);
-    int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
-    int sigwaitinfo(const scope sigset_t*, siginfo_t*);
 }
 else version (OpenBSD)
 {
@@ -3634,10 +2987,6 @@ else version (DragonFlyBSD)
         _sigval_t                 sigev_value;
         void function(_sigval_t)  sigev_notify_function;
     }
-
-    int sigqueue(pid_t, int, const sigval);
-    int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
-    int sigwaitinfo(const scope sigset_t*, siginfo_t*);
 }
 else version (Darwin)
 {
@@ -3661,84 +3010,68 @@ else version (Solaris)
         pthread_attr_t* sigev_notify_attributes;
         int __sigev_pad2;
     }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+/*
+int sigqueue(pid_t, int, const sigval);
+int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
+int sigwaitinfo(const scope sigset_t*, siginfo_t*);
+*/
+
+nothrow:
+@nogc:
 
+version (CRuntime_Glibc)
+{
+    int sigqueue(pid_t, int, const sigval);
+    int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
+    int sigwaitinfo(const scope sigset_t*, siginfo_t*);
+}
+else version (FreeBSD)
+{
+    int sigqueue(pid_t, int, const sigval);
+    int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
+    int sigwaitinfo(const scope sigset_t*, siginfo_t*);
+}
+else version (NetBSD)
+{
+    int sigqueue(pid_t, int, const sigval);
+    int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
+    int sigwaitinfo(const scope sigset_t*, siginfo_t*);
+}
+else version (OpenBSD)
+{
+}
+else version (DragonFlyBSD)
+{
+    int sigqueue(pid_t, int, const sigval);
+    int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
+    int sigwaitinfo(const scope sigset_t*, siginfo_t*);
+}
+else version (Darwin)
+{
+}
+else version (Solaris)
+{
     int sigqueue(pid_t, int, const sigval);
     int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
     int sigwaitinfo(const scope sigset_t*, siginfo_t*);
 }
 else version (CRuntime_Bionic)
 {
-    private enum __ARCH_SIGEV_PREAMBLE_SIZE = (int.sizeof * 2) + sigval.sizeof;
-    private enum SIGEV_MAX_SIZE = 64;
-    private enum SIGEV_PAD_SIZE = (SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE)
-                                  / int.sizeof;
-
-    struct sigevent
-    {
-        sigval      sigev_value;
-        int         sigev_signo;
-        int         sigev_notify;
-
-        union _sigev_un_t
-        {
-            int[SIGEV_PAD_SIZE] _pad;
-            int                 _tid;
-
-            struct _sigev_thread_t
-            {
-                void function(sigval) _function;
-                void*                 _attribute;
-            } _sigev_thread_t _sigev_thread;
-        } _sigev_un_t _sigev_un;
-    }
 }
 else version (CRuntime_Musl)
 {
-    struct sigevent
-    {
-        sigval sigev_value;
-        int sigev_signo;
-        int sigev_notify;
-        void function(sigval) sigev_notify_function;
-        pthread_attr_t *sigev_notify_attributes;
-        char[56 - 3 * c_long.sizeof] __pad = void;
-    }
+    int sigqueue(pid_t, int, const sigval);
+    int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
+    int sigwaitinfo(const scope sigset_t*, siginfo_t*);
 }
 else version (CRuntime_UClibc)
 {
-    private enum __SIGEV_MAX_SIZE = 64;
-
-    static if ( __WORDSIZE == 64 )
-    {
-        private enum __SIGEV_PAD_SIZE = ((__SIGEV_MAX_SIZE / int.sizeof) - 4);
-    }
-    else
-    {
-        private enum __SIGEV_PAD_SIZE = ((__SIGEV_MAX_SIZE / int.sizeof) - 3);
-    }
-
-    struct sigevent
-    {
-        sigval      sigev_value;
-        int         sigev_signo;
-        int         sigev_notify;
-
-        union _sigev_un_t
-        {
-            int[__SIGEV_PAD_SIZE] _pad;
-            pid_t                 _tid;
-
-            struct _sigev_thread_t
-            {
-                void function(sigval)   _function;
-                void*                   _attribute;
-            } _sigev_thread_t _sigev_thread;
-        } _sigev_un_t _sigev_un;
-    }
-
-    @property void function(sigval) sigev_notify_function(ref sigevent _sigevent) { return _sigevent._sigev_un._sigev_thread._function; }
-    @property void* sigev_notify_attributes(ref sigevent _sigevent) { return  _sigevent._sigev_un._sigev_thread._attribute; }
-
     int sigqueue(pid_t, int, const sigval);
     int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
     int sigwaitinfo(const scope sigset_t*, siginfo_t*);
diff --git a/libphobos/libdruntime/core/sys/posix/stdc/time.d b/libphobos/libdruntime/core/sys/posix/stdc/time.d
index 89029de09a8..d48a0ea3eda 100644
--- a/libphobos/libdruntime/core/sys/posix/stdc/time.d
+++ b/libphobos/libdruntime/core/sys/posix/stdc/time.d
@@ -52,7 +52,27 @@ struct tm
 public import core.sys.posix.sys.types : time_t, clock_t;
 
 ///
-version (OSX)
+version (CRuntime_Glibc)
+{
+    enum clock_t CLOCKS_PER_SEC = 1_000_000;
+    clock_t clock();
+}
+else version (CRuntime_Musl)
+{
+    enum clock_t CLOCKS_PER_SEC = 1_000_000;
+    clock_t clock();
+}
+else version (CRuntime_Bionic)
+{
+    enum clock_t CLOCKS_PER_SEC = 1_000_000;
+    clock_t clock();
+}
+else version (CRuntime_UClibc)
+{
+    enum clock_t CLOCKS_PER_SEC = 1_000_000;
+    clock_t clock();
+}
+else version (OSX)
 {
     enum clock_t CLOCKS_PER_SEC = 1_000_000; // was 100 until OSX 10.4/10.5
     version (X86)
@@ -90,26 +110,6 @@ else version (Solaris)
     enum clock_t CLOCKS_PER_SEC = 1_000_000;
     clock_t clock();
 }
-else version (CRuntime_Glibc)
-{
-    enum clock_t CLOCKS_PER_SEC = 1_000_000;
-    clock_t clock();
-}
-else version (CRuntime_Musl)
-{
-    enum clock_t CLOCKS_PER_SEC = 1_000_000;
-    clock_t clock();
-}
-else version (CRuntime_Bionic)
-{
-    enum clock_t CLOCKS_PER_SEC = 1_000_000;
-    clock_t clock();
-}
-else version (CRuntime_UClibc)
-{
-    enum clock_t CLOCKS_PER_SEC = 1_000_000;
-    clock_t clock();
-}
 else
 {
     static assert(0, "unsupported system");
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
index c8f92ec301b..077838d50aa 100644
--- a/libphobos/libdruntime/core/sys/posix/stdio.d
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -623,35 +623,35 @@ version (CRuntime_Glibc)
 {
     enum P_tmpdir  = "/tmp";
 }
-version (CRuntime_Musl)
+else version (CRuntime_Musl)
 {
     enum P_tmpdir  = "/tmp";
 }
-version (Darwin)
+else version (Darwin)
 {
     enum P_tmpdir  = "/var/tmp";
 }
-version (FreeBSD)
+else version (FreeBSD)
 {
     enum P_tmpdir  = "/var/tmp/";
 }
-version (NetBSD)
+else version (NetBSD)
 {
     enum P_tmpdir  = "/var/tmp/";
 }
-version (OpenBSD)
+else version (OpenBSD)
 {
     enum P_tmpdir  = "/tmp/";
 }
-version (DragonFlyBSD)
+else version (DragonFlyBSD)
 {
     enum P_tmpdir  = "/var/tmp/";
 }
-version (Solaris)
+else version (Solaris)
 {
     enum P_tmpdir  = "/var/tmp/";
 }
-version (CRuntime_UClibc)
+else version (CRuntime_UClibc)
 {
     enum P_tmpdir  = "/tmp";
 }
diff --git a/libphobos/libdruntime/core/sys/posix/sys/ioctl.d b/libphobos/libdruntime/core/sys/posix/sys/ioctl.d
index c6f21d6cd0a..36d1edc4ebc 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/ioctl.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/ioctl.d
@@ -31,7 +31,7 @@ version (Posix):
 extern (C) nothrow @nogc:
 @system:
 
-version (CRuntime_Glibc)
+version (linux)
 {
     import core.sys.posix.termios; // tcflag_t, speed_t, cc_t
 
@@ -326,8 +326,6 @@ version (CRuntime_Glibc)
     enum SIOCDEVPRIVATE = 0x89F0;
 
     enum SIOCPROTOPRIVATE = 0x89E0;
-
-    int ioctl(int __fd, c_ulong __request, ...);
 }
 else version (Darwin)
 {
@@ -348,8 +346,6 @@ else version (Darwin)
     enum uint TIOCSSIZE = TIOCSWINSZ;
 
     public import core.sys.posix.sys.filio; // File related ioctls
-
-    int ioctl(int fildes, c_ulong request, ...);
 }
 else version (FreeBSD)
 {
@@ -358,8 +354,6 @@ else version (FreeBSD)
         int len;
         void* buf;
     }
-
-    int ioctl(int, c_ulong, ...);
 }
 else version (NetBSD)
 {
@@ -370,8 +364,6 @@ else version (NetBSD)
         ushort ws_xpixel;
         ushort ws_ypixel;
     }
-
-    int ioctl(int, c_ulong, ...);
 }
 else version (OpenBSD)
 {
@@ -389,8 +381,6 @@ else version (OpenBSD)
     }
 
     public import core.sys.posix.sys.filio; // File related ioctls
-
-    int ioctl(int, c_ulong, ...);
 }
 else version (DragonFlyBSD)
 {
@@ -407,7 +397,38 @@ else version (DragonFlyBSD)
         ushort ws_xpixel;
         ushort ws_ypixel;
     }
+}
+else version (Solaris)
+{
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
 
+///
+version (CRuntime_Glibc)
+{
+    int ioctl(int __fd, c_ulong __request, ...);
+}
+else version (Darwin)
+{
+    int ioctl(int fildes, c_ulong request, ...);
+}
+else version (FreeBSD)
+{
+    int ioctl(int, c_ulong, ...);
+}
+else version (NetBSD)
+{
+    int ioctl(int, c_ulong, ...);
+}
+else version (OpenBSD)
+{
+    int ioctl(int, c_ulong, ...);
+}
+else version (DragonFlyBSD)
+{
     int ioctl(int, c_ulong, ...);
 }
 else version (Solaris)
@@ -420,331 +441,10 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
-
+    int ioctl(int, int, ...);
 }
 else version (CRuntime_UClibc)
 {
-    import core.sys.posix.termios;
-
-    enum _IOC_NRBITS = 8;
-    enum _IOC_TYPEBITS = 8;
-    enum _IOC_SIZEBITS = 14;
-    enum _IOC_DIRBITS = 2;
-
-    enum _IOC_NRMASK = (1 << _IOC_NRBITS) - 1;
-    enum _IOC_TYPEMASK = (1 << _IOC_TYPEBITS) - 1;
-    enum _IOC_SIZEMASK = (1 << _IOC_SIZEBITS) - 1;
-    enum _IOC_DIRMASK = (1 << _IOC_DIRBITS) - 1;
-
-    enum _IOC_NRSHIFT = 0;
-    enum _IOC_TYPESHIFT = _IOC_NRSHIFT + _IOC_NRBITS;
-    enum _IOC_SIZESHIFT = _IOC_TYPESHIFT + _IOC_TYPEBITS;
-    enum _IOC_DIRSHIFT = _IOC_SIZESHIFT + _IOC_SIZEBITS;
-
-    enum _IOC_NONE = 0;
-    enum _IOC_WRITE = 1;
-    enum _IOC_READ = 2;
-
-    extern (D) int _IOC(T = typeof(null))(int dir, int type, int nr)
-    {
-        return (dir << _IOC_DIRSHIFT) |
-               (type << _IOC_TYPESHIFT) |
-               (nr << _IOC_NRSHIFT) |
-               (is(T == typeof(null)) ? 0 : T.sizeof << _IOC_SIZESHIFT);
-    }
-
-    extern (D) int _IO(int type, int nr)
-    {
-        return _IOC(_IOC_NONE, type, nr);
-    }
-
-    extern (D) int _IOR(T)(int type, int nr)
-    {
-        return _IOC!T(_IOC_READ, type, nr);
-    }
-
-    extern (D) int _IOW(T)(int type, int nr)
-    {
-        return _IOC!T(_IOC_WRITE, type, nr);
-    }
-
-    extern (D) int _IOWR(T)(int type, int nr)
-    {
-        return _IOC!T(_IOC_READ | _IOC_WRITE, type, nr);
-    }
-
-    extern (D) int _IOR_BAD(T)(int type, int nr)
-    {
-        return _IOC!T(_IOC_READ, type, nr);
-    }
-
-    extern (D) int _IOW_BAD(T)(int type, int nr)
-    {
-        return _IOC!T(_IOC_WRITE, type, nr);
-    }
-
-    extern (D) int _IORW_BAD(T)(int type, int nr)
-    {
-        return _IOC!T(_IOC_READ | _IOC_WRITE, type, nr);
-    }
-
-    extern (D) int _IOC_DIR(int nr)
-    {
-        return (nr >> _IOC_DIRSHIFT) & _IOC_DIRMASK;
-    }
-
-    extern (D) int _IOC_TYPE(int nr)
-    {
-        return (nr >> _IOC_TYPESHIFT) & _IOC_TYPEMASK;
-    }
-
-    extern (D) int _IOC_NR(int nr)
-    {
-        return (nr >> _IOC_NRSHIFT) & _IOC_NRMASK;
-    }
-
-    extern (D) int _IOC_SIZE(int nr)
-    {
-        return (nr >> _IOC_SIZESHIFT) & _IOC_SIZEMASK;
-    }
-
-    enum IOC_IN = _IOC_WRITE << _IOC_DIRSHIFT;
-    enum IOC_OUT = _IOC_READ << _IOC_DIRSHIFT;
-    enum IOC_INOUT = (_IOC_READ | _IOC_WRITE) << _IOC_DIRSHIFT;
-    enum IOCSIZE_MASK = _IOC_SIZEMASK << _IOC_DIRSHIFT;
-    enum IOCSIZE_SHIFT = _IOC_SIZESHIFT;
-
-    enum NCCS = 19;
-
-    struct termios
-    {
-        tcflag_t c_iflag;
-        tcflag_t c_oflag;
-        tcflag_t c_cflag;
-        tcflag_t c_lflag;
-        cc_t c_line;
-        cc_t[NCCS] c_cc;
-    }
-
-    struct termios2
-    {
-        tcflag_t c_iflag;
-        tcflag_t c_oflag;
-        tcflag_t c_cflag;
-        tcflag_t c_lflag;
-        cc_t c_line;
-        cc_t[NCCS] c_cc;
-        speed_t c_ispeed;
-        speed_t c_ospeed;
-    }
-
-    alias termios2 ktermios;
-
-    struct winsize
-    {
-        ushort ws_row;
-        ushort ws_col;
-        ushort ws_xpixel;
-        ushort ws_ypixel;
-    }
-
-    enum NCC = 8;
-
-    struct termio
-    {
-        ushort c_iflag;
-        ushort c_oflag;
-        ushort c_cflag;
-        ushort c_lflag;
-        ubyte c_line;
-        ubyte[NCC] c_cc;
-    }
-
-    enum TIOCM_LE = 0x001;
-    enum TIOCM_DTR = 0x002;
-    enum TIOCM_RTS = 0x004;
-    enum TIOCM_ST = 0x008;
-    enum TIOCM_SR = 0x010;
-    enum TIOCM_CTS = 0x020;
-    enum TIOCM_CAR = 0x040;
-    enum TIOCM_RNG = 0x080;
-    enum TIOCM_DSR = 0x100;
-    enum TIOCM_CD = TIOCM_CAR;
-    enum TIOCM_RI = TIOCM_RNG;
-
-    enum N_TTY = 0;
-    enum N_SLIP = 1;
-    enum N_MOUSE = 2;
-    enum N_PPP = 3;
-    enum N_STRIP = 4;
-    enum N_AX25 = 5;
-    enum N_X25 = 6;
-    enum N_6PACK = 7;
-    enum N_MASC = 8;
-    enum N_R3964 = 9;
-    enum N_PROFIBUS_FDL = 10;
-    enum N_IRDA = 11;
-    enum N_SMSBLOCK = 12;
-    enum N_HDLC = 13;
-    enum N_SYNC_PPP = 14;
-    enum N_HCI = 15;
-
-    enum TCGETS = 0x5401;
-    enum TCSETS = 0x5402;
-    enum TCSETSW = 0x5403;
-    enum TCSETSF = 0x5404;
-    enum TCGETA = 0x5405;
-    enum TCSETA = 0x5406;
-    enum TCSETAW = 0x5407;
-    enum TCSETAF = 0x5408;
-    enum TCSBRK = 0x5409;
-    enum TCXONC = 0x540A;
-    enum TCFLSH = 0x540B;
-    enum TIOCEXCL = 0x540C;
-    enum TIOCNXCL = 0x540D;
-    enum TIOCSCTTY = 0x540E;
-    enum TIOCGPGRP = 0x540F;
-    enum TIOCSPGRP = 0x5410;
-    enum TIOCOUTQ = 0x5411;
-    enum TIOCSTI = 0x5412;
-    enum TIOCGWINSZ = 0x5413;
-    enum TIOCSWINSZ = 0x5414;
-    enum TIOCMGET = 0x5415;
-    enum TIOCMBIS = 0x5416;
-    enum TIOCMBIC = 0x5417;
-    enum TIOCMSET = 0x5418;
-    enum TIOCGSOFTCAR = 0x5419;
-    enum TIOCSSOFTCAR = 0x541A;
-    enum FIONREAD = 0x541B;
-    enum TIOCINQ = FIONREAD;
-    enum TIOCLINUX = 0x541C;
-    enum TIOCCONS = 0x541D;
-    enum TIOCGSERIAL = 0x541E;
-    enum TIOCSSERIAL = 0x541F;
-    enum TIOCPKT = 0x5420;
-    enum FIONBIO = 0x5421;
-    enum TIOCNOTTY = 0x5422;
-    enum TIOCSETD = 0x5423;
-    enum TIOCGETD = 0x5424;
-    enum TCSBRKP = 0x5425;
-    enum TIOCSBRK = 0x5427;
-    enum TIOCCBRK = 0x5428;
-    enum TIOCGSID = 0x5429;
-
-    enum TCGETS2 = _IOR!termios2('T', 0x2A);
-    enum TCSETS2 = _IOW!termios2('T', 0x2B);
-    enum TCSETSW2 = _IOW!termios2('T', 0x2C);
-    enum TCSETSF2 = _IOW!termios2('T', 0x2D);
-
-    enum TIOCGRS485 = 0x542E;
-    enum TIOCSRS485 = 0x542F;
-
-    enum TIOCGPTN   = _IOR!uint('T', 0x30);
-    enum TIOCSPTLCK = _IOW!int('T', 0x31);
-    enum TIOCGDEV   = _IOR!uint('T', 0x32);
-
-    enum TCGETX = 0x5432;
-    enum TCSETX = 0x5433;
-    enum TCSETXF = 0x5434;
-    enum TCSETXW = 0x5435;
-
-    enum TIOCSIG = _IOW!int('T', 0x36);
-
-    enum TIOCVHANGUP = 0x5437;
-
-    enum FIONCLEX = 0x5450;
-    enum FIOCLEX = 0x5451;
-    enum FIOASYNC = 0x5452;
-    enum TIOCSERCONFIG = 0x5453;
-    enum TIOCSERGWILD = 0x5454;
-    enum TIOCSERSWILD = 0x5455;
-    enum TIOCGLCKTRMIOS = 0x5456;
-    enum TIOCSLCKTRMIOS = 0x5457;
-    enum TIOCSERGSTRUCT = 0x5458;
-    enum TIOCSERGETLSR = 0x5459;
-    enum TIOCSERGETMULTI = 0x545A;
-    enum TIOCSERSETMULTI = 0x545B;
-
-    enum TIOCMIWAIT = 0x545C;
-    enum TIOCGICOUNT = 0x545D;
-
-    enum FIOQSIZE = 0x5460;
-
-    enum TIOCPKT_DATA = 0;
-    enum TIOCPKT_FLUSHREAD = 1;
-    enum TIOCPKT_FLUSHWRITE = 2;
-    enum TIOCPKT_STOP = 4;
-    enum TIOCPKT_START = 8;
-    enum TIOCPKT_NOSTOP = 16;
-    enum TIOCPKT_DOSTOP = 32;
-    enum TIOCPKT_IOCTL = 64;
-
-    enum TIOCSER_TEMT = 0x01;
-
-    enum SIOCADDRT = 0x890B;
-    enum SIOCDELRT = 0x890C;
-    enum SIOCRTMSG = 0x890D;
-
-    enum SIOCGIFNAME = 0x8910;
-    enum SIOCSIFLINK = 0x8911;
-    enum SIOCGIFCONF = 0x8912;
-    enum SIOCGIFFLAGS = 0x8913;
-    enum SIOCSIFFLAGS = 0x8914;
-    enum SIOCGIFADDR = 0x8915;
-    enum SIOCSIFADDR = 0x8916;
-    enum SIOCGIFDSTADDR = 0x8917;
-    enum SIOCSIFDSTADDR = 0x8918;
-    enum SIOCGIFBRDADDR = 0x8919;
-    enum SIOCSIFBRDADDR = 0x891a;
-    enum SIOCGIFNETMASK = 0x891b;
-    enum SIOCSIFNETMASK = 0x891c;
-    enum SIOCGIFMETRIC = 0x891d;
-    enum SIOCSIFMETRIC = 0x891e;
-    enum SIOCGIFMEM = 0x891f;
-    enum SIOCSIFMEM = 0x8920;
-    enum SIOCGIFMTU = 0x8921;
-    enum SIOCSIFMTU = 0x8922;
-    enum SIOCSIFNAME = 0x8923;
-    enum SIOCSIFHWADDR = 0x8924;
-    enum SIOCGIFENCAP = 0x8925;
-    enum SIOCSIFENCAP = 0x8926;
-    enum SIOCGIFHWADDR = 0x8927;
-    enum SIOCGIFSLAVE = 0x8929;
-    enum SIOCSIFSLAVE = 0x8930;
-    enum SIOCADDMULTI = 0x8931;
-    enum SIOCDELMULTI = 0x8932;
-    enum SIOCGIFINDEX = 0x8933;
-    enum SIOGIFINDEX = SIOCGIFINDEX;
-    enum SIOCSIFPFLAGS = 0x8934;
-    enum SIOCGIFPFLAGS = 0x8935;
-    enum SIOCDIFADDR = 0x8936;
-    enum SIOCSIFHWBROADCAST = 0x8937;
-    enum SIOCGIFCOUNT = 0x8938;
-
-    enum SIOCGIFBR = 0x8940;
-    enum SIOCSIFBR = 0x8941;
-
-    enum SIOCGIFTXQLEN = 0x8942;
-    enum SIOCSIFTXQLEN = 0x8943;
-
-    enum SIOCDARP = 0x8953;
-    enum SIOCGARP = 0x8954;
-    enum SIOCSARP = 0x8955;
-
-    enum SIOCDRARP = 0x8960;
-    enum SIOCGRARP = 0x8961;
-    enum SIOCSRARP = 0x8962;
-
-    enum SIOCGIFMAP = 0x8970;
-    enum SIOCSIFMAP = 0x8971;
-
-    enum SIOCADDDLCI = 0x8980;
-    enum SIOCDELDLCI = 0x8981;
-
-    enum SIOCDEVPRIVATE = 0x89F0;
-
-    enum SIOCPROTOPRIVATE = 0x89E0;
-
     int ioctl(int __fd, c_ulong __request, ...);
 }
 else
diff --git a/libphobos/libdruntime/core/sys/posix/sys/ipc.d b/libphobos/libdruntime/core/sys/posix/sys/ipc.d
index d397a28ec5a..18a6cbd4d53 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/ipc.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/ipc.d
@@ -52,11 +52,9 @@ IPC_PRIVATE
 IPC_RMID
 IPC_SET
 IPC_STAT
-
-key_t ftok(const scope char*, int);
 */
 
-version (CRuntime_Glibc)
+version (linux)
 {
     struct ipc_perm
     {
@@ -82,8 +80,6 @@ version (CRuntime_Glibc)
     enum IPC_RMID       = 0;
     enum IPC_SET        = 1;
     enum IPC_STAT       = 2;
-
-    key_t ftok(const scope char*, int);
 }
 else version (Darwin)
 {
@@ -122,8 +118,6 @@ else version (FreeBSD)
     enum IPC_RMID       = 0;
     enum IPC_SET        = 1;
     enum IPC_STAT       = 2;
-
-    key_t ftok(const scope char*, int);
 }
 else version (NetBSD)
 {
@@ -147,8 +141,6 @@ else version (NetBSD)
     enum IPC_RMID       = 0;
     enum IPC_SET        = 1;
     enum IPC_STAT       = 2;
-
-    key_t ftok(const scope char*, int);
 }
 else version (OpenBSD)
 {
@@ -172,8 +164,6 @@ else version (OpenBSD)
     enum IPC_RMID       = 0;
     enum IPC_SET        = 1;
     enum IPC_STAT       = 2;
-
-    key_t ftok(const scope char*, int);
 }
 else version (DragonFlyBSD)
 {
@@ -197,79 +187,53 @@ else version (DragonFlyBSD)
     enum IPC_RMID       = 0;
     enum IPC_SET        = 1;
     enum IPC_STAT       = 2;
-
-    key_t ftok(const scope char*, int);
 }
-else version (CRuntime_Bionic)
+else
 {
-    // All except ftok are from the linux kernel headers. Latest Bionic headers
-    // don't use this legacy definition anymore, consider updating.
-    version (D_LP64)
-    {
-        struct ipc_perm
-        {
-            key_t   key;
-            uint    uid;
-            uint    gid;
-            uint    cuid;
-            uint    cgid;
-            mode_t  mode;
-            ushort  seq;
-        }
-    }
-    else
-    {
-        struct ipc_perm
-        {
-            key_t   key;
-            ushort  uid;
-            ushort  gid;
-            ushort  cuid;
-            ushort  cgid;
-            mode_t  mode;
-            ushort  seq;
-        }
-    }
-
-    enum IPC_CREAT      = 0x0200; // 01000
-    enum IPC_EXCL       = 0x0400; // 02000
-    enum IPC_NOWAIT     = 0x0800; // 04000
+    static assert(false, "Unsupported platform");
+}
 
-    enum key_t IPC_PRIVATE = 0;
+/*
+key_t ftok(const scope char*, int);
+*/
 
-    enum IPC_RMID       = 0;
-    enum IPC_SET        = 1;
-    enum IPC_STAT       = 2;
+version (CRuntime_Glibc)
+{
+    key_t ftok(const scope char*, int);
+}
+else version (Darwin)
+{
 
+}
+else version (FreeBSD)
+{
+    key_t ftok(const scope char*, int);
+}
+else version (NetBSD)
+{
+    key_t ftok(const scope char*, int);
+}
+else version (OpenBSD)
+{
+    key_t ftok(const scope char*, int);
+}
+else version (DragonFlyBSD)
+{
+    key_t ftok(const scope char*, int);
+}
+else version (CRuntime_Bionic)
+{
+    key_t ftok(const scope char*, int);
+}
+else version (CRuntime_Musl)
+{
     key_t ftok(const scope char*, int);
 }
 else version (CRuntime_UClibc)
 {
-    struct ipc_perm
-    {
-        key_t   __key;
-        uid_t   uid;
-        gid_t   gid;
-        uid_t   cuid;
-        gid_t   cgid;
-        ushort  mode;
-        ushort  __pad1;
-        ushort  __seq;
-        ushort  __pad2;
-        c_ulong __unused1;
-        c_ulong __unused2;
-    }
-
-    enum IPC_CREAT      = 0x0200; // 01000
-    enum IPC_EXCL       = 0x0400; // 02000
-    enum IPC_NOWAIT     = 0x0800; // 04000
-
-    enum key_t IPC_PRIVATE = 0;
-
-    enum IPC_RMID       = 0;
-    enum IPC_SET        = 1;
-    enum IPC_STAT       = 2;
-    enum IPC_INFO       = 3;
-
     key_t ftok(const scope char*, int);
 }
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/sys/mman.d b/libphobos/libdruntime/core/sys/posix/sys/mman.d
index 18da10246e4..33ce88feb4e 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/mman.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/mman.d
@@ -54,6 +54,53 @@ extern (C) nothrow @nogc:
 int posix_madvise(void*, size_t, int);
 */
 
+version (CRuntime_Glibc)
+{
+    static if (__USE_XOPEN2K)
+    {
+        int posix_madvise(void *__addr, size_t __len, int __advice);
+    }
+}
+else version (Darwin)
+{
+    int posix_madvise(void *addr, size_t len, int advice);
+}
+else version (FreeBSD)
+{
+    int posix_madvise(void *addr, size_t len, int advice);
+}
+else version (NetBSD)
+{
+    int posix_madvise(void *addr, size_t len, int advice);
+}
+else version (OpenBSD)
+{
+    int posix_madvise(void *addr, size_t len, int advice);
+}
+else version (DragonFlyBSD)
+{
+    int posix_madvise(void *addr, size_t len, int advice);
+}
+else version (Solaris)
+{
+}
+else version (CRuntime_Bionic)
+{
+}
+else version (CRuntime_Musl)
+{
+    int posix_madvise(void *, size_t, int);
+}
+else version (CRuntime_UClibc)
+{
+    int posix_madvise(void *__addr, size_t __len, int __advice);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+
 //
 // Advisory Information and either Memory Mapped Files or Shared Memory Objects (MC1)
 //
@@ -65,24 +112,20 @@ POSIX_MADV_WILLNEED
 POSIX_MADV_DONTNEED
 */
 
-version (CRuntime_Glibc)
+version (linux)
 {
     version (Alpha)
         private enum __POSIX_MADV_DONTNEED = 6;
     else
         private enum __POSIX_MADV_DONTNEED = 4;
 
-    static if (__USE_XOPEN2K)
+    enum
     {
-        enum
-        {
-            POSIX_MADV_NORMAL = 0,
-            POSIX_MADV_RANDOM = 1,
-            POSIX_MADV_SEQUENTIAL = 2,
-            POSIX_MADV_WILLNEED = 3,
-            POSIX_MADV_DONTNEED = __POSIX_MADV_DONTNEED,
-        }
-        int posix_madvise(void *__addr, size_t __len, int __advice);
+        POSIX_MADV_NORMAL = 0,
+        POSIX_MADV_RANDOM = 1,
+        POSIX_MADV_SEQUENTIAL = 2,
+        POSIX_MADV_WILLNEED = 3,
+        POSIX_MADV_DONTNEED = __POSIX_MADV_DONTNEED,
     }
 }
 else version (Darwin)
@@ -92,7 +135,6 @@ else version (Darwin)
     enum POSIX_MADV_SEQUENTIAL  = 2;
     enum POSIX_MADV_WILLNEED    = 3;
     enum POSIX_MADV_DONTNEED    = 4;
-    int posix_madvise(void *addr, size_t len, int advice);
 }
 else version (FreeBSD)
 {
@@ -101,7 +143,6 @@ else version (FreeBSD)
     enum POSIX_MADV_SEQUENTIAL  = 2;
     enum POSIX_MADV_WILLNEED    = 3;
     enum POSIX_MADV_DONTNEED    = 4;
-    int posix_madvise(void *addr, size_t len, int advice);
 }
 else version (NetBSD)
 {
@@ -110,7 +151,6 @@ else version (NetBSD)
     enum POSIX_MADV_SEQUENTIAL  = 2;
     enum POSIX_MADV_WILLNEED    = 3;
     enum POSIX_MADV_DONTNEED    = 4;
-    int posix_madvise(void *addr, size_t len, int advice);
 }
 else version (OpenBSD)
 {
@@ -119,7 +159,6 @@ else version (OpenBSD)
     enum POSIX_MADV_SEQUENTIAL  = 2;
     enum POSIX_MADV_WILLNEED    = 3;
     enum POSIX_MADV_DONTNEED    = 4;
-    int posix_madvise(void *addr, size_t len, int advice);
 }
 else version (DragonFlyBSD)
 {
@@ -128,38 +167,10 @@ else version (DragonFlyBSD)
     enum POSIX_MADV_SEQUENTIAL  = 2;
     enum POSIX_MADV_WILLNEED    = 3;
     enum POSIX_MADV_DONTNEED    = 4;
-    int posix_madvise(void *addr, size_t len, int advice);
 }
 else version (Solaris)
 {
 }
-else version (CRuntime_Bionic)
-{
-}
-else version (CRuntime_Musl)
-{
-    enum
-    {
-        POSIX_MADV_NORMAL = 0,
-        POSIX_MADV_RANDOM = 1,
-        POSIX_MADV_SEQUENTIAL = 2,
-        POSIX_MADV_WILLNEED = 3,
-        POSIX_MADV_DONTNEED = 4,
-    }
-    int posix_madvise(void *, size_t, int);
-}
-else version (CRuntime_UClibc)
-{
-    enum
-    {
-        POSIX_MADV_NORMAL = 0,
-        POSIX_MADV_RANDOM = 1,
-        POSIX_MADV_SEQUENTIAL = 2,
-        POSIX_MADV_WILLNEED = 3,
-        POSIX_MADV_DONTNEED = 4,
-    }
-    int posix_madvise(void *__addr, size_t __len, int __advice);
-}
 else
 {
     static assert(false, "Unsupported platform");
@@ -175,7 +186,7 @@ PROT_EXEC
 PROT_NONE
 */
 
-version (CRuntime_Glibc)
+version (linux)
 {
     enum PROT_NONE      = 0x0;
     enum PROT_READ      = 0x1;
@@ -224,27 +235,6 @@ else version (Solaris)
     enum PROT_WRITE = 0x02;
     enum PROT_EXEC = 0x04;
 }
-else version (CRuntime_Bionic)
-{
-    enum PROT_NONE = 0x00;
-    enum PROT_READ = 0x01;
-    enum PROT_WRITE = 0x02;
-    enum PROT_EXEC = 0x04;
-}
-else version (CRuntime_Musl)
-{
-    enum PROT_NONE      = 0x0;
-    enum PROT_READ      = 0x1;
-    enum PROT_WRITE     = 0x2;
-    enum PROT_EXEC      = 0x4;
-}
-else version (CRuntime_UClibc)
-{
-    enum PROT_NONE      = 0x0;
-    enum PROT_READ      = 0x1;
-    enum PROT_WRITE     = 0x2;
-    enum PROT_EXEC      = 0x4;
-}
 else
 {
     static assert(false, "Unsupported platform");
@@ -337,11 +327,9 @@ MAP_FAILED (MF|SHM)
 MS_ASYNC (MF|SIO)
 MS_SYNC (MF|SIO)
 MS_INVALIDATE (MF|SIO)
-
-int msync(void*, size_t, int); (MF|SIO)
 */
 
-version (CRuntime_Glibc)
+version (linux)
 {
     enum MAP_SHARED     = 0x01;
     enum MAP_PRIVATE    = 0x02;
@@ -405,8 +393,6 @@ version (CRuntime_Glibc)
         enum MS_INVALIDATE = 2;
         enum MS_SYNC = 4;
     }
-
-    int msync(void*, size_t, int);
 }
 else version (Darwin)
 {
@@ -420,8 +406,6 @@ else version (Darwin)
     enum MS_ASYNC       = 0x0001;
     enum MS_INVALIDATE  = 0x0002;
     enum MS_SYNC        = 0x0010;
-
-    int msync(void*, size_t, int);
 }
 else version (FreeBSD)
 {
@@ -435,8 +419,6 @@ else version (FreeBSD)
     enum MS_SYNC        = 0x0000;
     enum MS_ASYNC       = 0x0001;
     enum MS_INVALIDATE  = 0x0002;
-
-    int msync(void*, size_t, int);
 }
 else version (NetBSD)
 {
@@ -450,9 +432,6 @@ else version (NetBSD)
     enum MS_SYNC        = 0x0004;
     enum MS_ASYNC       = 0x0001;
     enum MS_INVALIDATE  = 0x0002;
-
-    int __msync13(void*, size_t, int);
-    alias msync = __msync13;
 }
 else version (OpenBSD)
 {
@@ -467,8 +446,6 @@ else version (OpenBSD)
     enum MS_SYNC        = 0x0002;
     enum MS_ASYNC       = 0x0001;
     enum MS_INVALIDATE  = 0x0004;
-
-    int msync(void*, size_t, int);
 }
 else version (DragonFlyBSD)
 {
@@ -482,8 +459,6 @@ else version (DragonFlyBSD)
     enum MS_SYNC        = 0x0000;
     enum MS_ASYNC       = 0x0001;
     enum MS_INVALIDATE  = 0x0002;
-
-    int msync(void*, size_t, int);
 }
 else version (Solaris)
 {
@@ -497,72 +472,55 @@ else version (Solaris)
     enum MS_SYNC = 0x0004;
     enum MS_ASYNC = 0x0001;
     enum MS_INVALIDATE  = 0x0002;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+/*
+int msync(void*, size_t, int); (MF|SIO)
+*/
 
+version (CRuntime_Glibc)
+{
+    int msync(void*, size_t, int);
+}
+else version (Darwin)
+{
+    int msync(void*, size_t, int);
+}
+else version (FreeBSD)
+{
+    int msync(void*, size_t, int);
+}
+else version (NetBSD)
+{
+    int __msync13(void*, size_t, int);
+    alias msync = __msync13;
+}
+else version (OpenBSD)
+{
+    int msync(void*, size_t, int);
+}
+else version (DragonFlyBSD)
+{
+    int msync(void*, size_t, int);
+}
+else version (Solaris)
+{
     int msync(void*, size_t, int);
 }
 else version (CRuntime_Bionic)
 {
-    enum MAP_SHARED     = 0x0001;
-    enum MAP_PRIVATE    = 0x0002;
-    enum MAP_FIXED      = 0x0010;
-    enum MAP_ANON       = 0x0020;
-
-    enum MAP_FAILED     = cast(void*)-1;
-
-    enum MS_SYNC        = 4;
-    enum MS_ASYNC       = 1;
-    enum MS_INVALIDATE  = 2;
-
     int msync(const scope void*, size_t, int);
 }
 else version (CRuntime_Musl)
 {
-    enum MAP_SHARED     = 0x01;
-    enum MAP_PRIVATE    = 0x02;
-    enum MAP_FIXED      = 0x10;
-
-    enum MAP_FAILED     = cast(void*) -1;
-    enum MAP_ANON = 0x20;
-    enum MS_ASYNC = 1;
-    enum MS_INVALIDATE = 2;
-    enum MS_SYNC = 4;
     int msync(void*, size_t, int);
 }
 else version (CRuntime_UClibc)
 {
-    enum MAP_SHARED     = 0x01;
-    enum MAP_PRIVATE    = 0x02;
-    enum MAP_FIXED      = 0x10;
-
-    enum MAP_FAILED     = cast(void*) -1;
-
-    version (X86_64)
-    {
-        enum MAP_ANON       = 0x20;
-        enum MS_ASYNC       = 1;
-        enum MS_INVALIDATE  = 2;
-        enum MS_SYNC        = 4;
-    }
-    else version (MIPS32)
-    {
-        enum MAP_ANON       = 0x0800;
-        enum MS_ASYNC       = 1;
-        enum MS_INVALIDATE  = 2;
-        enum MS_SYNC        = 4;
-    }
-    else version (ARM)
-    {
-        enum MAP_ANON       = 0x020;
-        enum MS_ASYNC       = 1;
-        enum MS_INVALIDATE  = 2;
-        enum MS_SYNC        = 4;
-    }
-    else
-    {
-        static assert(false, "Architecture not supported.");
-    }
-
-
     int msync(void*, size_t, int);
 }
 else
@@ -576,12 +534,9 @@ else
 /*
 MCL_CURRENT
 MCL_FUTURE
-
-int mlockall(int);
-int munlockall();
 */
 
-version (CRuntime_Glibc)
+version (linux)
 {
     version (SPARC_Any) enum
     {
@@ -603,89 +558,96 @@ version (CRuntime_Glibc)
         MCL_CURRENT = 1,
         MCL_FUTURE = 2,
     }
-
-    int mlockall(int);
-    int munlockall();
-
 }
 else version (Darwin)
 {
     enum MCL_CURRENT    = 0x0001;
     enum MCL_FUTURE     = 0x0002;
-
-    int mlockall(int);
-    int munlockall();
 }
 else version (FreeBSD)
 {
     enum MCL_CURRENT    = 0x0001;
     enum MCL_FUTURE     = 0x0002;
-
-    int mlockall(int);
-    int munlockall();
 }
 else version (NetBSD)
 {
     enum MCL_CURRENT    = 0x0001;
     enum MCL_FUTURE     = 0x0002;
-
-    int mlockall(int);
-    int munlockall();
 }
 else version (OpenBSD)
 {
     enum MCL_CURRENT    = 0x0001;
     enum MCL_FUTURE     = 0x0002;
-
-    int mlockall(int);
-    int munlockall();
 }
 else version (DragonFlyBSD)
 {
     enum MCL_CURRENT    = 0x0001;
     enum MCL_FUTURE     = 0x0002;
-
-    int mlockall(int);
-    int munlockall();
 }
 else version (Solaris)
 {
     enum MCL_CURRENT = 0x0001;
     enum MCL_FUTURE = 0x0002;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
 
+/*
+int mlockall(int);
+int munlockall();
+*/
+
+version (CRuntime_Glibc)
+{
+    int mlockall(int);
+    int munlockall();
+}
+else version (Darwin)
+{
+    int mlockall(int);
+    int munlockall();
+}
+else version (FreeBSD)
+{
+    int mlockall(int);
+    int munlockall();
+}
+else version (NetBSD)
+{
+    int mlockall(int);
+    int munlockall();
+}
+else version (OpenBSD)
+{
+    int mlockall(int);
+    int munlockall();
+}
+else version (DragonFlyBSD)
+{
+    int mlockall(int);
+    int munlockall();
+}
+else version (Solaris)
+{
     int mlockall(int);
     int munlockall();
 }
 else version (CRuntime_Bionic)
 {
-    enum MCL_CURRENT = 1;
-    enum MCL_FUTURE  = 2;
-
     int mlockall(int);
     int munlockall();
 }
 else version (CRuntime_Musl)
 {
-    enum
-    {
-        MCL_CURRENT = 1,
-        MCL_FUTURE = 2,
-    }
-
     int mlockall(int);
     int munlockall();
 }
 else version (CRuntime_UClibc)
 {
-    enum
-    {
-        MCL_CURRENT = 1,
-        MCL_FUTURE = 2,
-    }
-
     int mlockall(int);
     int munlockall();
-
 }
 else
 {
diff --git a/libphobos/libdruntime/core/sys/posix/sys/resource.d b/libphobos/libdruntime/core/sys/posix/sys/resource.d
index c5d584c5804..5ab01744067 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/resource.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/resource.d
@@ -52,12 +52,6 @@ enum
     RUSAGE_CHILDREN,
 }
 
-struct rlimit
-{
-    rlim_t rlim_cur;
-    rlim_t rlim_max;
-}
-
 struct rusage
 {
     timeval ru_utime;
@@ -74,19 +68,10 @@ enum
     RLIMIT_STACK,
     RLIMIT_AS,
 }
-
-int getpriority(int, id_t);
-int getrlimit(int, rlimit*);
-int getrusage(int, rusage*);
-int setpriority(int, id_t, int);
-int setrlimit(int, const rlimit*);
 */
 
-
-version (CRuntime_Glibc)
+version (linux)
 {
-    // rusage and some other constants in the Bionic section below really
-    // come from the linux kernel headers, but they're all mixed right now.
     enum
     {
         PRIO_PROCESS = 0,
@@ -111,6 +96,7 @@ version (CRuntime_Glibc)
     {
         RUSAGE_SELF     =  0,
         RUSAGE_CHILDREN = -1,
+        RUSAGE_THREAD = 1
     }
 
     struct rusage
@@ -131,6 +117,8 @@ version (CRuntime_Glibc)
         c_long ru_nsignals;
         c_long ru_nvcsw;
         c_long ru_nivcsw;
+        version (CRuntime_Musl)
+            c_long[16] __reserved;
     }
 
     enum
@@ -200,9 +188,8 @@ else version (FreeBSD)
     enum
     {
         RLIM_INFINITY   = (cast(rlim_t)((cast(ulong) 1 << 63) - 1)),
-        // FreeBSD explicitly does not define the following:
-        //RLIM_SAVED_MAX,
-        //RLIM_SAVED_CUR,
+        RLIM_SAVED_MAX  = RLIM_INFINITY,
+        RLIM_SAVED_CUR  = RLIM_INFINITY,
     }
 
     enum
@@ -258,9 +245,8 @@ else version (NetBSD)
     enum
     {
         RLIM_INFINITY   = (cast(rlim_t)((cast(ulong) 1 << 63) - 1)),
-        // FreeBSD explicitly does not define the following:
-        //RLIM_SAVED_MAX,
-        //RLIM_SAVED_CUR,
+        RLIM_SAVED_MAX = RLIM_INFINITY,
+        RLIM_SAVED_CUR = RLIM_INFINITY,
     }
 
     enum
@@ -375,9 +361,8 @@ else version (DragonFlyBSD)
     enum
     {
         RLIM_INFINITY   = (cast(rlim_t)((cast(ulong) 1 << 63) - 1)),
-        // DragonFlyBSD explicitly does not define the following:
-        //RLIM_SAVED_MAX,
-        //RLIM_SAVED_CUR,
+        RLIM_SAVED_MAX  = RLIM_INFINITY,
+        RLIM_SAVED_CUR  = RLIM_INFINITY,
     }
 
     enum
@@ -474,162 +459,22 @@ else version (Solaris)
         RLIMIT_AS     = 6,
     }
 }
-else version (CRuntime_Bionic)
-{
-    enum
-    {
-        PRIO_PROCESS = 0,
-        PRIO_PGRP    = 1,
-        PRIO_USER    = 2,
-    }
-
-    alias c_ulong rlim_t;
-    enum RLIM_INFINITY = cast(c_ulong)(~0UL);
-
-    enum
-    {
-        RUSAGE_SELF     =  0,
-        RUSAGE_CHILDREN = -1,
-    }
+else
+    static assert (false, "Unsupported platform");
 
-    struct rusage
-    {
-        timeval ru_utime;
-        timeval ru_stime;
-        c_long ru_maxrss;
-        c_long ru_ixrss;
-        c_long ru_idrss;
-        c_long ru_isrss;
-        c_long ru_minflt;
-        c_long ru_majflt;
-        c_long ru_nswap;
-        c_long ru_inblock;
-        c_long ru_oublock;
-        c_long ru_msgsnd;
-        c_long ru_msgrcv;
-        c_long ru_nsignals;
-        c_long ru_nvcsw;
-        c_long ru_nivcsw;
-    }
-
-    enum
-    {
-        RLIMIT_CORE   = 4,
-        RLIMIT_CPU    = 0,
-        RLIMIT_DATA   = 2,
-        RLIMIT_FSIZE  = 1,
-        RLIMIT_NOFILE = 7,
-        RLIMIT_STACK  = 3,
-        RLIMIT_AS     = 9,
-    }
-}
-else version (CRuntime_Musl)
+/*
+struct rlimit
 {
-    alias ulong rlim_t;
-    enum RLIM_INFINITY = cast(c_ulong)(~0UL);
-
-    int getrlimit(int, rlimit*);
-    int setrlimit(int, const scope rlimit*);
-    alias getrlimit getrlimit64;
-    alias setrlimit setrlimit64;
-    enum
-    {
-        RUSAGE_SELF = 0,
-        RUSAGE_CHILDREN = -1,
-        RUSAGE_THREAD = 1
-    }
-    struct rusage
-    {
-        timeval ru_utime;
-        timeval ru_stime;
-        c_long ru_maxrss;
-        c_long ru_ixrss;
-        c_long ru_idrss;
-        c_long ru_isrss;
-        c_long ru_minflt;
-        c_long ru_majflt;
-        c_long ru_nswap;
-        c_long ru_inblock;
-        c_long ru_oublock;
-        c_long ru_msgsnd;
-        c_long ru_msgrcv;
-        c_long ru_nsignals;
-        c_long ru_nvcsw;
-        c_long ru_nivcsw;
-        c_long[16] __reserved;
-    }
-
-    enum
-    {
-        RLIMIT_CPU    = 0,
-        RLIMIT_FSIZE  = 1,
-        RLIMIT_DATA   = 2,
-        RLIMIT_STACK  = 3,
-        RLIMIT_CORE   = 4,
-        RLIMIT_NOFILE = 7,
-        RLIMIT_AS     = 9,
-    }
+    rlim_t rlim_cur;
+    rlim_t rlim_max;
 }
-else version (CRuntime_UClibc)
-{
-    enum
-    {
-        PRIO_PROCESS = 0,
-        PRIO_PGRP    = 1,
-        PRIO_USER    = 2,
-    }
-
-    static if (__USE_FILE_OFFSET64)
-         alias ulong rlim_t;
-    else
-         alias c_ulong rlim_t;
-
-    static if (__USE_FILE_OFFSET64)
-        enum RLIM_INFINITY = 0xffffffffffffffffUL;
-    else
-        enum RLIM_INFINITY = cast(c_ulong)(~0UL);
-
-    enum RLIM_SAVED_MAX = RLIM_INFINITY;
-    enum RLIM_SAVED_CUR = RLIM_INFINITY;
-
-    enum
-    {
-        RUSAGE_SELF     =  0,
-        RUSAGE_CHILDREN = -1,
-    }
-
-    struct rusage
-    {
-        timeval ru_utime;
-        timeval ru_stime;
-        c_long ru_maxrss;
-        c_long ru_ixrss;
-        c_long ru_idrss;
-        c_long ru_isrss;
-        c_long ru_minflt;
-        c_long ru_majflt;
-        c_long ru_nswap;
-        c_long ru_inblock;
-        c_long ru_oublock;
-        c_long ru_msgsnd;
-        c_long ru_msgrcv;
-        c_long ru_nsignals;
-        c_long ru_nvcsw;
-        c_long ru_nivcsw;
-    }
 
-    enum
-    {
-        RLIMIT_CORE   = 4,
-        RLIMIT_CPU    = 0,
-        RLIMIT_DATA   = 2,
-        RLIMIT_FSIZE  = 1,
-        RLIMIT_NOFILE = 7,
-        RLIMIT_STACK  = 3,
-        RLIMIT_AS     = 9,
-    }
-}
-else static assert (false, "Unsupported platform");
+int getpriority(int, id_t);
+int getrlimit(int, rlimit*);
+int getrusage(int, rusage*);
+int setpriority(int, id_t, int);
+int setrlimit(int, const rlimit*);
+*/
 
 struct rlimit
 {
@@ -641,40 +486,6 @@ version (CRuntime_Glibc)
 {
     int getpriority(int, id_t);
     int setpriority(int, id_t, int);
-}
-else version (FreeBSD)
-{
-    int getpriority(int, int);
-    int setpriority(int, int, int);
-}
-else version (DragonFlyBSD)
-{
-    int getpriority(int, int);
-    int setpriority(int, int, int);
-}
-else version (CRuntime_Bionic)
-{
-    int getpriority(int, int);
-    int setpriority(int, int, int);
-}
-else version (Solaris)
-{
-    int getpriority(int, id_t);
-    int setpriority(int, id_t, int);
-}
-else version (Darwin)
-{
-    int getpriority(int, id_t);
-    int setpriority(int, id_t, int);
-}
-else version (CRuntime_UClibc)
-{
-    int getpriority(int, id_t);
-    int setpriority(int, id_t, int);
-}
-
-version (CRuntime_Glibc)
-{
     static if (__USE_FILE_OFFSET64)
     {
         int getrlimit64(int, rlimit*);
@@ -689,50 +500,76 @@ version (CRuntime_Glibc)
     }
     int getrusage(int, rusage*);
 }
-else version (CRuntime_Bionic)
+else version (FreeBSD)
 {
+    int getpriority(int, int);
     int getrlimit(int, rlimit*);
     int getrusage(int, rusage*);
+    int setpriority(int, int, int);
     int setrlimit(int, const scope rlimit*);
 }
-else version (Darwin)
+else version (NetBSD)
 {
+    int getpriority(int, int);
     int getrlimit(int, rlimit*);
     int getrusage(int, rusage*);
+    int setpriority(int, int, int);
     int setrlimit(int, const scope rlimit*);
 }
-else version (FreeBSD)
+else version (OpenBSD)
 {
+    int getpriority(int, int);
     int getrlimit(int, rlimit*);
     int getrusage(int, rusage*);
+    int setpriority(int, int, int);
     int setrlimit(int, const scope rlimit*);
 }
-else version (NetBSD)
+else version (DragonFlyBSD)
 {
+    int getpriority(int, int);
     int getrlimit(int, rlimit*);
     int getrusage(int, rusage*);
+    int setpriority(int, int, int);
     int setrlimit(int, const scope rlimit*);
 }
-else version (OpenBSD)
+else version (CRuntime_Bionic)
 {
+    int getpriority(int, int);
     int getrlimit(int, rlimit*);
     int getrusage(int, rusage*);
+    int setpriority(int, int, int);
     int setrlimit(int, const scope rlimit*);
 }
-else version (DragonFlyBSD)
+else version (CRuntime_Musl)
 {
+    int getpriority(int, id_t);
+    int setpriority(int, id_t, int);
     int getrlimit(int, rlimit*);
-    int getrusage(int, rusage*);
     int setrlimit(int, const scope rlimit*);
+    alias getrlimit getrlimit64;
+    alias setrlimit setrlimit64;
+    int getrusage(int, rusage*);
 }
 else version (Solaris)
 {
+    int getpriority(int, int);
     int getrlimit(int, rlimit*);
     int getrusage(int, rusage*);
+    int setpriority(int, int, int);
+    int setrlimit(int, const scope rlimit*);
+}
+else version (Darwin)
+{
+    int getpriority(int, id_t);
+    int getrlimit(int, rlimit*);
+    int getrusage(int, rusage*);
+    int setpriority(int, id_t, int);
     int setrlimit(int, const scope rlimit*);
 }
 else version (CRuntime_UClibc)
 {
+    int getpriority(int, id_t);
+    int setpriority(int, id_t, int);
     static if (__USE_FILE_OFFSET64)
     {
         int getrlimit64(int, rlimit*);
@@ -747,3 +584,5 @@ else version (CRuntime_UClibc)
     }
     int getrusage(int, rusage*);
 }
+else
+    static assert (false, "Unsupported platform");
diff --git a/libphobos/libdruntime/core/sys/posix/sys/shm.d b/libphobos/libdruntime/core/sys/posix/sys/shm.d
index 2e85096ba4a..ce341418f36 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/shm.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/shm.d
@@ -38,8 +38,6 @@ extern (C) nothrow @nogc:
 SHM_RDONLY
 SHM_RND
 
-SHMLBA
-
 shmatt_t
 
 struct shmid_ds
@@ -53,20 +51,13 @@ struct shmid_ds
     time_t      shm_dtime;
     time_t      shm_ctime;
 }
-
-void* shmat(int, const scope void*, int);
-int   shmctl(int, int, shmid_ds*);
-int   shmdt(const scope void*);
-int   shmget(key_t, size_t, int);
 */
 
-version (CRuntime_Glibc)
+version (linux)
 {
     enum SHM_RDONLY     = 0x01000; // 010000
     enum SHM_RND        = 0x02000; // 020000
-
-    int   __getpagesize();
-    alias __getpagesize SHMLBA;
+    enum SHM_REMAP      = 0x4000; // 040000
 
     alias c_ulong   shmatt_t;
 
@@ -87,17 +78,11 @@ version (CRuntime_Glibc)
         c_ulong     __unused4;
         c_ulong     __unused5;
     }
-
-    void* shmat(int, const scope void*, int);
-    int   shmctl(int, int, shmid_ds*);
-    int   shmdt(const scope void*);
-    int   shmget(key_t, size_t, int);
 }
 else version (FreeBSD)
 {
     enum SHM_RDONLY     = 0x01000; // 010000
     enum SHM_RND        = 0x02000; // 020000
-    enum SHMLBA         = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT)
 
     alias c_ulong   shmatt_t;
 
@@ -125,17 +110,11 @@ else version (FreeBSD)
          time_t      shm_dtime;
          time_t      shm_ctime;
     }
-
-    void* shmat(int, const scope void*, int);
-    int   shmctl(int, int, shmid_ds*);
-    int   shmdt(const scope void*);
-    int   shmget(key_t, size_t, int);
 }
 else version (NetBSD)
 {
     enum SHM_RDONLY     = 0x01000; // 010000
     enum SHM_RND        = 0x02000; // 020000
-    enum SHMLBA         = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT)
 
     alias c_ulong   shmatt_t;
 
@@ -151,17 +130,11 @@ else version (NetBSD)
         time_t          shm_ctime;
         void*           shm_internal;
     }
-
-    void* shmat(int, const scope void*, int);
-    int   shmctl(int, int, shmid_ds*);
-    int   shmdt(const scope void*);
-    int   shmget(key_t, size_t, int);
 }
 else version (OpenBSD)
 {
     enum SHM_RDONLY     = 0x01000; // 010000
     enum SHM_RND        = 0x02000; // 020000
-    enum SHMLBA         = 1 << _MAX_PAGE_SHIFT;
 
     alias short shmatt_t;
 
@@ -180,17 +153,11 @@ else version (OpenBSD)
         c_long   __shm_ctimensec;
         void*      shm_internal;
     }
-
-    void* shmat(int, const scope void*, int);
-    int   shmctl(int, int, shmid_ds*);
-    int   shmdt(const scope void*);
-    int   shmget(key_t, size_t, int);
 }
 else version (DragonFlyBSD)
 {
     enum SHM_RDONLY     = 0x01000; // 010000
     enum SHM_RND        = 0x02000; // 020000
-    enum SHMLBA         = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT)
 
     alias c_ulong   shmatt_t;
 
@@ -206,76 +173,103 @@ else version (DragonFlyBSD)
          time_t         shm_ctime;
          private void*  shm_internal;
     }
+}
+else version (Darwin)
+{
+
+}
+else version (Solaris)
+{
+
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+/*
+SHMLBA
+
+void* shmat(int, const scope void*, int);
+int   shmctl(int, int, shmid_ds*);
+int   shmdt(const scope void*);
+int   shmget(key_t, size_t, int);
+*/
+
+version (CRuntime_Glibc)
+{
+    int   __getpagesize();
+    alias __getpagesize SHMLBA;
 
     void* shmat(int, const scope void*, int);
     int   shmctl(int, int, shmid_ds*);
     int   shmdt(const scope void*);
     int   shmget(key_t, size_t, int);
 }
-else version (Darwin)
+else version (FreeBSD)
 {
+    enum SHMLBA = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT)
 
+    void* shmat(int, const scope void*, int);
+    int   shmctl(int, int, shmid_ds*);
+    int   shmdt(const scope void*);
+    int   shmget(key_t, size_t, int);
 }
-else version (CRuntime_UClibc)
+else version (NetBSD)
 {
-    enum SHM_RDONLY     = 0x1000; // 010000
-    enum SHM_RND        = 0x2000; // 020000
-    enum SHM_REMAP      = 0x4000; // 040000
+    enum SHMLBA = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT)
 
-    int   __getpagesize();
-    alias __getpagesize SHMLBA;
+    void* shmat(int, const scope void*, int);
+    int   shmctl(int, int, shmid_ds*);
+    int   shmdt(const scope void*);
+    int   shmget(key_t, size_t, int);
+}
+else version (OpenBSD)
+{
+    enum SHMLBA = 1 << _MAX_PAGE_SHIFT;
 
-    alias c_ulong   shmatt_t;
+    void* shmat(int, const scope void*, int);
+    int   shmctl(int, int, shmid_ds*);
+    int   shmdt(const scope void*);
+    int   shmget(key_t, size_t, int);
+}
+else version (DragonFlyBSD)
+{
+    enum SHMLBA = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT)
 
-    version (X86_64)
-        enum includeUnused  = false;
-    else version (MIPS32)
-        enum includeUnused  = false;
-    else
-        enum includeUnused  = true;
+    void* shmat(int, const scope void*, int);
+    int   shmctl(int, int, shmid_ds*);
+    int   shmdt(const scope void*);
+    int   shmget(key_t, size_t, int);
+}
+else version (Darwin)
+{
 
-    struct shmid_ds
-    {
-        ipc_perm    shm_perm;
-        size_t      shm_segsz;
-        time_t      shm_atime;
-        static if (includeUnused) c_ulong     __unused1;
-        time_t      shm_dtime;
-        static if (includeUnused) c_ulong     __unused2;
-        time_t      shm_ctime;
-        static if (includeUnused) c_ulong     __unused3;
-        pid_t       shm_cpid;
-        pid_t       shm_lpid;
-        shmatt_t    shm_nattch;
-        c_ulong     __unused4;
-        c_ulong     __unused5;
-    }
+}
+else version (Solaris)
+{
 
-    struct shminfo
-    {
-        c_ulong shmmax;
-        c_ulong shmmin;
-        c_ulong shmmni;
-        c_ulong shmseg;
-        c_ulong shmall;
-        c_ulong __unused1;
-        c_ulong __unused2;
-        c_ulong __unused3;
-        c_ulong __unused4;
-    }
+}
+else version (CRuntime_Musl)
+{
+    enum SHMLBA = 4096;
 
-    struct shm_info
-    {
-        int used_ids;
-        c_ulong shm_tot;
-        c_ulong shm_rss;
-        c_ulong shm_swp;
-        c_ulong swap_attempts;
-        c_ulong swap_successes;
-    }
+    void* shmat(int, const scope void*, int);
+    int   shmctl(int, int, shmid_ds*);
+    int   shmdt(const scope void*);
+    int   shmget(key_t, size_t, int);
+}
+else version (CRuntime_UClibc)
+{
+    int   __getpagesize();
+    alias __getpagesize SHMLBA;
 
     void* shmat(int, const scope void*, int);
     int   shmctl(int, int, shmid_ds*);
     int   shmdt(const scope void*);
     int   shmget(key_t, size_t, int);
 }
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/sys/socket.d b/libphobos/libdruntime/core/sys/posix/sys/socket.d
index 6e0cfd3ac3d..670ead73c64 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/socket.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/socket.d
@@ -137,31 +137,10 @@ AF_UNSPEC
 SHUT_RD
 SHUT_RDWR
 SHUT_WR
-
-int     accept(int, sockaddr*, socklen_t*);
-int     bind(int, const scope sockaddr*, socklen_t);
-int     connect(int, const scope sockaddr*, socklen_t);
-int     getpeername(int, sockaddr*, socklen_t*);
-int     getsockname(int, sockaddr*, socklen_t*);
-int     getsockopt(int, int, int, void*, socklen_t*);
-int     listen(int, int);
-ssize_t recv(int, void*, size_t, int);
-ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*);
-ssize_t recvmsg(int, msghdr*, int);
-ssize_t send(int, const scope void*, size_t, int);
-ssize_t sendmsg(int, const scope msghdr*, int);
-ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t);
-int     setsockopt(int, int, int, const scope void*, socklen_t);
-int     shutdown(int, int);
-int     socket(int, int, int);
-int     sockatmark(int);
-int     socketpair(int, int, int, ref int[2]);
 */
 
-version (CRuntime_Glibc)
+version (linux)
 {
-    // Some of the constants below and from the Bionic section are really from
-    // the linux kernel headers.
     alias uint   socklen_t;
     alias ushort sa_family_t;
 
@@ -174,14 +153,14 @@ version (CRuntime_Glibc)
     private enum : size_t
     {
         _SS_SIZE    = 128,
-        _SS_PADSIZE = _SS_SIZE - (c_ulong.sizeof * 2)
+        _SS_PADSIZE = _SS_SIZE - c_ulong.sizeof - sa_family_t.sizeof
     }
 
     struct sockaddr_storage
     {
         sa_family_t ss_family;
-        c_ulong     __ss_align;
         byte[_SS_PADSIZE] __ss_padding;
+        c_ulong     __ss_align;
     }
 
     struct msghdr
@@ -200,10 +179,6 @@ version (CRuntime_Glibc)
         size_t cmsg_len;
         int    cmsg_level;
         int    cmsg_type;
-        static if ( false /* (!is( __STRICT_ANSI__ ) && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L */ )
-        {
-            ubyte[1] __cmsg_data;
-        }
     }
 
     enum : uint
@@ -211,14 +186,7 @@ version (CRuntime_Glibc)
         SCM_RIGHTS = 0x01
     }
 
-    static if ( false /* (!is( __STRICT_ANSI__ ) && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L */ )
-    {
-        extern (D) ubyte[1] CMSG_DATA( cmsghdr* cmsg ) pure nothrow @nogc { return cmsg.__cmsg_data; }
-    }
-    else
-    {
-        extern (D) inout(ubyte)*   CMSG_DATA( return scope inout(cmsghdr)* cmsg ) pure nothrow @nogc { return cast(ubyte*)( cmsg + 1 ); }
-    }
+    extern (D) inout(ubyte)*   CMSG_DATA( return scope inout(cmsghdr)* cmsg ) pure nothrow @nogc { return cast(ubyte*)( cmsg + 1 ); }
 
     private inout(cmsghdr)* __cmsg_nxthdr(inout(msghdr)*, inout(cmsghdr)*) pure nothrow @nogc;
     extern (D)  inout(cmsghdr)* CMSG_NXTHDR(inout(msghdr)* msg, inout(cmsghdr)* cmsg) pure nothrow @nogc
@@ -534,10 +502,19 @@ version (CRuntime_Glibc)
     else
         static assert(0, "unimplemented");
 
-    enum
+    version (CRuntime_Glibc)
+    {
+        enum
+        {
+            SOMAXCONN   = 4096
+        }
+    }
+    else
     {
-        // https://sourceware.org/git/?p=glibc.git;a=commit;f=sysdeps/unix/sysv/linux/bits/socket.h;h=96958e2700f5b4f4d1183a0606b2b9848a53ea44
-        SOMAXCONN       = 4096
+        enum
+        {
+            SOMAXCONN   = 128
+        }
     }
 
     enum : uint
@@ -571,25 +548,6 @@ version (CRuntime_Glibc)
         SHUT_WR,
         SHUT_RDWR
     }
-
-    int     accept(int, scope sockaddr*, scope socklen_t*);
-    int     bind(int, const scope sockaddr*, socklen_t);
-    int     connect(int, const scope sockaddr*, socklen_t);
-    int     getpeername(int, scope sockaddr*, scope socklen_t*);
-    int     getsockname(int, scope sockaddr*, scope socklen_t*);
-    int     getsockopt(int, int, int, scope void*, scope socklen_t*);
-    int     listen(int, int) @safe;
-    ssize_t recv(int, scope void*, size_t, int);
-    ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*);
-    ssize_t recvmsg(int, scope msghdr*, int);
-    ssize_t send(int, const scope void*, size_t, int);
-    ssize_t sendmsg(int, const scope msghdr*, int);
-    ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t);
-    int     setsockopt(int, int, int, const scope void*, socklen_t);
-    int     shutdown(int, int) @safe;
-    int     socket(int, int, int) @safe;
-    int     sockatmark(int) @safe;
-    int     socketpair(int, int, int, ref int[2]) @safe;
 }
 else version (Darwin)
 {
@@ -727,25 +685,6 @@ else version (Darwin)
         SHUT_WR,
         SHUT_RDWR
     }
-
-    int     accept(int, scope sockaddr*, scope socklen_t*);
-    int     bind(int, const scope sockaddr*, socklen_t);
-    int     connect(int, const scope sockaddr*, socklen_t);
-    int     getpeername(int, scope sockaddr*, scope socklen_t*);
-    int     getsockname(int, scope sockaddr*, scope socklen_t*);
-    int     getsockopt(int, int, int, scope void*, scope socklen_t*);
-    int     listen(int, int) @safe;
-    ssize_t recv(int, scope void*, size_t, int);
-    ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*);
-    ssize_t recvmsg(int, scope msghdr*, int);
-    ssize_t send(int, const scope void*, size_t, int);
-    ssize_t sendmsg(int, const scope msghdr*, int);
-   [...]

[diff truncated at 524288 bytes]


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-02-16 10:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 10:15 [gcc r12-7258] d: Merge upstream dmd 52844d4b1, druntime dbd0c874, phobos 896b1d0e1 Iain Buclaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).