]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Merge upstream dmd 60bfa0ee7, druntime 94bd5bcb, phobos 3a1cd9a01.
authorIain Buclaw <ibuclaw@gdcproject.org>
Mon, 16 May 2022 16:30:46 +0000 (18:30 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Mon, 16 May 2022 17:07:45 +0000 (19:07 +0200)
D front-end changes:

    - Import dmd v2.100.0.
    - Add bit fields to D, enabled via the -fpreview=bitfields switch.
    - Removed the -ftransition=markdown and -frevert=markdown switches.
    - Added new trait `__traits(classInstanceAlignment)' to provide the
      required data alignment for classes.
    - The check for `pragma(crt_constructor)' and `pragma(crt_destructor)'
      linkage has been relaxed to allow all `void()' signatures.
    - ImportC parser now recognizes the `typeof(...)' operator.

D runtime changes:

    - Import druntime v2.100.0.

Phobos changes:

    - Import phobos v2.100.0.
    - To comply with dip1000, `std.socket.Socket` methods now accept only
      `scope' arrays.
    - The `fill', `alignSize', `align2', and `align4' methods of
      `std.outbuffer.OutBuffer' have been extended to allow specifying a custom
      value when pre-filling or padding the buffer.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 60bfa0ee7.
* dmd/VERSION: Update version to v2.100.0.
* d-builtins.cc (d_init_versions): Update for new front-end interface.
* d-codegen.cc (d_decl_context): Use resolvedLinkage to get
declaration linkage.
(build_struct_literal): Track offset in bits.
* d-gimplify.cc (d_gimplify_modify_expr): Check both operands for a
bit-field reference.
* d-lang.cc (d_handle_option): Handle -fpreview=bitfields, remove
-frevert=markdown and -ftransition=vmarkdown.
(d_post_options): Set flag_rtti and flag_exceptions if -fno-druntime
was seen on command-line.
(d_parse_file): Update for new front-end interface.
(d_type_promotes_to): Use resolvedLinkage to get declaration linkage.
* decl.cc (make_thunk): Likewise.
* expr.cc (ExprVisitor::visit (CatAssignExp *)): Remove lowering for
appending of an element or array to another array.
* lang.opt (fpreview=bitfields): New option.
(frevert=markdown): Remove.
(ftransition=vmarkdown): Remove.
* types.cc (layout_aggregate_members): Ignore anonymous fields in
total count.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 94bd5bcb.
* libdruntime/Makefile.am (ALL_DRUNTIME_INSTALL_DSOURCES): Add
$(DRUNTIME_DSOURCES_ELF).
(ALL_DRUNTIME_SOURCES): Likewise.
(DRUNTIME_DSOURCES_ELF): New variable.
* libdruntime/Makefile.in: Regenerate.
* src/MERGE: Merge upstream phobos 3a1cd9a01.
* testsuite/libphobos.init_fini/custom_gc.d: Update test.

229 files changed:
gcc/d/d-builtins.cc
gcc/d/d-codegen.cc
gcc/d/d-gimplify.cc
gcc/d/d-lang.cc
gcc/d/decl.cc
gcc/d/dmd/MERGE
gcc/d/dmd/README.md
gcc/d/dmd/VERSION
gcc/d/dmd/clone.d
gcc/d/dmd/common/bitfields.d
gcc/d/dmd/common/outbuffer.d
gcc/d/dmd/cond.d
gcc/d/dmd/constfold.d
gcc/d/dmd/cparse.d
gcc/d/dmd/cppmangle.d
gcc/d/dmd/dcast.d
gcc/d/dmd/dclass.d
gcc/d/dmd/declaration.d
gcc/d/dmd/declaration.h
gcc/d/dmd/dinterpret.d
gcc/d/dmd/dmangle.d
gcc/d/dmd/dmodule.d
gcc/d/dmd/doc.d
gcc/d/dmd/dscope.d
gcc/d/dmd/dsymbol.d
gcc/d/dmd/dsymbolsem.d
gcc/d/dmd/dtemplate.d
gcc/d/dmd/dtoh.d
gcc/d/dmd/escape.d
gcc/d/dmd/expression.d
gcc/d/dmd/expressionsem.d
gcc/d/dmd/func.d
gcc/d/dmd/globals.d
gcc/d/dmd/globals.h
gcc/d/dmd/hdrgen.d
gcc/d/dmd/id.d
gcc/d/dmd/initsem.d
gcc/d/dmd/json.d
gcc/d/dmd/mtype.d
gcc/d/dmd/mtype.h
gcc/d/dmd/nogc.d
gcc/d/dmd/objc.d
gcc/d/dmd/optimize.d
gcc/d/dmd/parse.d
gcc/d/dmd/safe.d
gcc/d/dmd/semantic2.d
gcc/d/dmd/semantic3.d
gcc/d/dmd/statementsem.d
gcc/d/dmd/tokens.d
gcc/d/dmd/traits.d
gcc/d/dmd/typesem.d
gcc/d/dmd/utils.d
gcc/d/expr.cc
gcc/d/lang.opt
gcc/d/types.cc
gcc/testsuite/gdc.test/compilable/aggr_alignment.d
gcc/testsuite/gdc.test/compilable/compile1.d
gcc/testsuite/gdc.test/compilable/cppmangle.d
gcc/testsuite/gdc.test/compilable/dbitfield.d [new file with mode: 0644]
gcc/testsuite/gdc.test/compilable/ddoc_markdown_breaks_verbose.d [deleted file]
gcc/testsuite/gdc.test/compilable/ddoc_markdown_code_verbose.d [deleted file]
gcc/testsuite/gdc.test/compilable/ddoc_markdown_emphasis_verbose.d [deleted file]
gcc/testsuite/gdc.test/compilable/ddoc_markdown_headings_verbose.d [deleted file]
gcc/testsuite/gdc.test/compilable/ddoc_markdown_links_verbose.d [deleted file]
gcc/testsuite/gdc.test/compilable/ddoc_markdown_lists_verbose.d [deleted file]
gcc/testsuite/gdc.test/compilable/ddoc_markdown_quote_verbose.d [deleted file]
gcc/testsuite/gdc.test/compilable/ddoc_markdown_tables_verbose.d [deleted file]
gcc/testsuite/gdc.test/compilable/dtoh_21217.d
gcc/testsuite/gdc.test/compilable/dtoh_AliasDeclaration.d
gcc/testsuite/gdc.test/compilable/dtoh_AliasDeclaration_98.d
gcc/testsuite/gdc.test/compilable/dtoh_AnonDeclaration.d
gcc/testsuite/gdc.test/compilable/dtoh_CPPNamespaceDeclaration.d
gcc/testsuite/gdc.test/compilable/dtoh_ClassDeclaration.d
gcc/testsuite/gdc.test/compilable/dtoh_StructDeclaration.d
gcc/testsuite/gdc.test/compilable/dtoh_TemplateDeclaration.d
gcc/testsuite/gdc.test/compilable/dtoh_UnionDeclaration.d
gcc/testsuite/gdc.test/compilable/dtoh_VarDeclaration.d
gcc/testsuite/gdc.test/compilable/dtoh_cpp98_compat.d
gcc/testsuite/gdc.test/compilable/dtoh_enum.d
gcc/testsuite/gdc.test/compilable/dtoh_enum_cpp98.d
gcc/testsuite/gdc.test/compilable/dtoh_expressions.d
gcc/testsuite/gdc.test/compilable/dtoh_extern_type.d
gcc/testsuite/gdc.test/compilable/dtoh_forwarding.d
gcc/testsuite/gdc.test/compilable/dtoh_functions.d
gcc/testsuite/gdc.test/compilable/dtoh_ignored.d
gcc/testsuite/gdc.test/compilable/dtoh_invalid_identifiers.d
gcc/testsuite/gdc.test/compilable/dtoh_mangling.d
gcc/testsuite/gdc.test/compilable/dtoh_names.d
gcc/testsuite/gdc.test/compilable/dtoh_protection.d
gcc/testsuite/gdc.test/compilable/dtoh_required_symbols.d
gcc/testsuite/gdc.test/compilable/dtoh_special_enum.d
gcc/testsuite/gdc.test/compilable/dtoh_unittest_block.d
gcc/testsuite/gdc.test/compilable/dtoh_verbose.d
gcc/testsuite/gdc.test/compilable/test17590.d
gcc/testsuite/gdc.test/compilable/test20427.d [new file with mode: 0644]
gcc/testsuite/gdc.test/compilable/test23047.d [new file with mode: 0644]
gcc/testsuite/gdc.test/compilable/test23087.d [new file with mode: 0644]
gcc/testsuite/gdc.test/compilable/test23089.d [new file with mode: 0644]
gcc/testsuite/gdc.test/compilable/test23097.d [new file with mode: 0644]
gcc/testsuite/gdc.test/compilable/test23105.d [new file with mode: 0644]
gcc/testsuite/gdc.test/compilable/test3004.d
gcc/testsuite/gdc.test/compilable/vcg-ast.d
gcc/testsuite/gdc.test/fail_compilation/attributediagnostic.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/b6227.d
gcc/testsuite/gdc.test/fail_compilation/betterc.d
gcc/testsuite/gdc.test/fail_compilation/biterrors.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/biterrors2.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/biterrors3.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/biterrors4.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/commaexp.d
gcc/testsuite/gdc.test/fail_compilation/cppvar.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/dbitfields.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/diag10805.d
gcc/testsuite/gdc.test/fail_compilation/diag10862.d
gcc/testsuite/gdc.test/fail_compilation/dip25.d
gcc/testsuite/gdc.test/fail_compilation/dtor_attributes.d
gcc/testsuite/gdc.test/fail_compilation/dtorfields_attributes.d
gcc/testsuite/gdc.test/fail_compilation/e7804_1.d
gcc/testsuite/gdc.test/fail_compilation/extra-files/test23109/object.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/fail109.d
gcc/testsuite/gdc.test/fail_compilation/fail12604.d
gcc/testsuite/gdc.test/fail_compilation/fail13902.d
gcc/testsuite/gdc.test/fail_compilation/fail16001.d
gcc/testsuite/gdc.test/fail_compilation/fail16575.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/fail16772.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/fail196.d
gcc/testsuite/gdc.test/fail_compilation/fail19759.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/fail19881.d
gcc/testsuite/gdc.test/fail_compilation/fail20691.d
gcc/testsuite/gdc.test/fail_compilation/fail21092.d
gcc/testsuite/gdc.test/fail_compilation/fail21206.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/fail21275.d
gcc/testsuite/gdc.test/fail_compilation/fail21314.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/fail21868b.d
gcc/testsuite/gdc.test/fail_compilation/fail23108a.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/fail23108b.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/fail23109.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/fail3703.d
gcc/testsuite/gdc.test/fail_compilation/fail_scope.d
gcc/testsuite/gdc.test/fail_compilation/ice10949.d
gcc/testsuite/gdc.test/fail_compilation/ice14844.d
gcc/testsuite/gdc.test/fail_compilation/ice22377.d
gcc/testsuite/gdc.test/fail_compilation/ice23097.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/ice9254a.d
gcc/testsuite/gdc.test/fail_compilation/ice9254b.d
gcc/testsuite/gdc.test/fail_compilation/ice9254c.d
gcc/testsuite/gdc.test/fail_compilation/imports/test23109a.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/imports/test23109b.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/imports/test23109c.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/issue3827.d
gcc/testsuite/gdc.test/fail_compilation/no_Throwable.d
gcc/testsuite/gdc.test/fail_compilation/retscope.d
gcc/testsuite/gdc.test/fail_compilation/retscope2.d
gcc/testsuite/gdc.test/fail_compilation/retscope6.d
gcc/testsuite/gdc.test/fail_compilation/safe_gshared.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/safe_pointer_index.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/test13536.d
gcc/testsuite/gdc.test/fail_compilation/test14496.d
gcc/testsuite/gdc.test/fail_compilation/test15191.d
gcc/testsuite/gdc.test/fail_compilation/test15373.d
gcc/testsuite/gdc.test/fail_compilation/test16188.d
gcc/testsuite/gdc.test/fail_compilation/test16365.d
gcc/testsuite/gdc.test/fail_compilation/test17284.d
gcc/testsuite/gdc.test/fail_compilation/test17423.d
gcc/testsuite/gdc.test/fail_compilation/test17868b.d
gcc/testsuite/gdc.test/fail_compilation/test18130.d
gcc/testsuite/gdc.test/fail_compilation/test18282.d
gcc/testsuite/gdc.test/fail_compilation/test18484.d
gcc/testsuite/gdc.test/fail_compilation/test20245.d
gcc/testsuite/gdc.test/fail_compilation/test20569.d
gcc/testsuite/gdc.test/fail_compilation/test21198.d
gcc/testsuite/gdc.test/fail_compilation/test21204.d
gcc/testsuite/gdc.test/fail_compilation/test21665.d
gcc/testsuite/gdc.test/fail_compilation/test22145.d
gcc/testsuite/gdc.test/fail_compilation/test22593.d
gcc/testsuite/gdc.test/fail_compilation/test9150.d
gcc/testsuite/gdc.test/fail_compilation/traits.d
gcc/testsuite/gdc.test/fail_compilation/udaparams.d
gcc/testsuite/gdc.test/runnable/bit.d [new file with mode: 0644]
gcc/testsuite/gdc.test/runnable/dbitfields.d [new file with mode: 0644]
gcc/testsuite/gdc.test/runnable/interpret.d
gcc/testsuite/gdc.test/runnable/test17868b.d
gcc/testsuite/gdc.test/runnable/test20734.d [new file with mode: 0644]
gcc/testsuite/gdc.test/runnable/test21416.d [new file with mode: 0644]
gcc/testsuite/gdc.test/runnable/test23083.d [new file with mode: 0644]
gcc/testsuite/gdc.test/runnable/testcontracts.d
libphobos/libdruntime/MERGE
libphobos/libdruntime/Makefile.am
libphobos/libdruntime/Makefile.in
libphobos/libdruntime/__builtins.di
libphobos/libdruntime/core/internal/array/appending.d
libphobos/libdruntime/core/internal/array/utils.d
libphobos/libdruntime/core/internal/traits.d
libphobos/libdruntime/core/lifetime.d
libphobos/libdruntime/core/memory.d
libphobos/libdruntime/core/simd.d
libphobos/libdruntime/core/sys/dragonflybsd/sys/elf32.d
libphobos/libdruntime/core/sys/dragonflybsd/sys/elf64.d
libphobos/libdruntime/core/sys/dragonflybsd/sys/elf_common.d
libphobos/libdruntime/core/sys/elf/package.d [new file with mode: 0644]
libphobos/libdruntime/core/sys/freebsd/sys/elf32.d
libphobos/libdruntime/core/sys/freebsd/sys/elf64.d
libphobos/libdruntime/core/sys/freebsd/sys/elf_common.d
libphobos/libdruntime/core/sys/linux/elf.d
libphobos/libdruntime/core/sys/netbsd/sys/elf32.d
libphobos/libdruntime/core/sys/netbsd/sys/elf64.d
libphobos/libdruntime/core/sys/netbsd/sys/elf_common.d
libphobos/libdruntime/core/sys/openbsd/sys/elf32.d
libphobos/libdruntime/core/sys/openbsd/sys/elf64.d
libphobos/libdruntime/core/sys/openbsd/sys/elf_common.d
libphobos/libdruntime/core/sys/posix/sys/socket.d
libphobos/libdruntime/core/sys/solaris/sys/elf.d
libphobos/libdruntime/core/sys/windows/objbase.d
libphobos/libdruntime/core/sys/windows/unknwn.d
libphobos/libdruntime/core/thread/osthread.d
libphobos/libdruntime/core/thread/threadbase.d
libphobos/libdruntime/object.d
libphobos/libdruntime/rt/lifetime.d
libphobos/src/MERGE
libphobos/src/std/exception.d
libphobos/src/std/experimental/logger/core.d
libphobos/src/std/math/exponential.d
libphobos/src/std/math/hardware.d
libphobos/src/std/outbuffer.d
libphobos/src/std/socket.d
libphobos/src/std/sumtype.d
libphobos/src/std/traits.d
libphobos/src/std/typecons.d
libphobos/testsuite/libphobos.init_fini/custom_gc.d

index 7e7fb75bdc5c8a336a694940ec8dcb4b0f990864..cd9748c1de1179d810cd0eb329d24ae52cfaa41a 100644 (file)
@@ -475,7 +475,7 @@ d_init_versions (void)
   if (flag_pie)
     VersionCondition::addPredefinedGlobalIdent ("D_PIE");
 
-  if (global.params.doDocComments)
+  if (global.params.ddoc.doOutput)
     VersionCondition::addPredefinedGlobalIdent ("D_Ddoc");
 
   if (global.params.useUnitTests)
index bb96b2f8d28f9c197a90a878d8cfe9343a871265..22090a8c75534f16abc99603cd7378a387d94531 100644 (file)
@@ -76,7 +76,7 @@ d_decl_context (Dsymbol *dsym)
         but only for extern(D) symbols.  */
       if (parent->isModule ())
        {
-         if ((decl != NULL && decl->linkage != LINK::d)
+         if ((decl != NULL && decl->resolvedLinkage () != LINK::d)
              || (ad != NULL && ad->classKind != ClassKind::d))
            return NULL_TREE;
 
@@ -1165,7 +1165,7 @@ build_struct_literal (tree type, vec <constructor_elt, va_gc> *init)
     }
 
   vec <constructor_elt, va_gc> *ve = NULL;
-  HOST_WIDE_INT offset = 0;
+  HOST_WIDE_INT bitoffset = 0;
   bool constant_p = true;
   bool finished = false;
 
@@ -1210,11 +1210,11 @@ build_struct_literal (tree type, vec <constructor_elt, va_gc> *init)
 
       if (is_initialized)
        {
-         HOST_WIDE_INT fieldpos = int_byte_position (field);
+         HOST_WIDE_INT fieldpos = int_bit_position (field);
          gcc_assert (value != NULL_TREE);
 
          /* Must not initialize fields that overlap.  */
-         if (fieldpos < offset)
+         if (fieldpos < bitoffset)
            {
              /* Find the nearest user defined type and field.  */
              tree vtype = type;
@@ -1243,12 +1243,9 @@ build_struct_literal (tree type, vec <constructor_elt, va_gc> *init)
            finished = true;
        }
 
-      /* Move offset to the next position in the struct.  */
-      if (TREE_CODE (type) == RECORD_TYPE)
-       {
-         offset = int_byte_position (field)
-           + int_size_in_bytes (TREE_TYPE (field));
-       }
+      /* Move bit offset to the next position in the struct.  */
+      if (TREE_CODE (type) == RECORD_TYPE && DECL_SIZE (field))
+       bitoffset = int_bit_position (field) + tree_to_shwi (DECL_SIZE (field));
 
       /* If all initializers have been assigned, there's nothing else to do.  */
       if (vec_safe_is_empty (init))
index a98089b7ccac604fcaae6cea7ff7e7a1f0da354e..36b76da3acc8f7e8419f08d697f2b8e1ba097c59 100644 (file)
@@ -109,7 +109,8 @@ d_gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
     }
 
   /* Same as above, but for bit-field assignments.  */
-  if (bit_field_ref (op0) && TREE_TYPE (op0) != TREE_TYPE (op1))
+  if ((bit_field_ref (op0) || bit_field_ref (op1))
+      && TREE_TYPE (op0) != TREE_TYPE (op1))
     {
       TREE_OPERAND (*expr_p, 1) = convert (TREE_TYPE (op0), op1);
       return GS_OK;
index 9adcabdf7cfafff597b35301cd32adc21bedbcdd..d1f4959f1195bcfc1e08c08695eba09ae81d5517 100644 (file)
@@ -478,21 +478,21 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
       break;
 
     case OPT_fdoc:
-      global.params.doDocComments = value;
+      global.params.ddoc.doOutput = value;
       break;
 
     case OPT_fdoc_dir_:
-      global.params.doDocComments = true;
-      global.params.docdir = arg;
+      global.params.ddoc.doOutput = true;
+      global.params.ddoc.dir = arg;
       break;
 
     case OPT_fdoc_file_:
-      global.params.doDocComments = true;
-      global.params.docname = arg;
+      global.params.ddoc.doOutput = true;
+      global.params.ddoc.name = arg;
       break;
 
     case OPT_fdoc_inc_:
-      global.params.ddocfiles.push (arg);
+      global.params.ddoc.files.push (arg);
       break;
 
     case OPT_fdruntime:
@@ -500,13 +500,12 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
       break;
 
     case OPT_fdump_c___spec_:
-      if (global.params.doCxxHdrGeneration == CxxHeaderMode::none)
-       global.params.doCxxHdrGeneration = CxxHeaderMode::silent;
-      global.params.cxxhdrname = arg;
+      global.params.cxxhdr.doOutput = true;
+      global.params.cxxhdr.name = arg;
       break;
 
     case OPT_fdump_c___spec_verbose:
-      global.params.doCxxHdrGeneration = CxxHeaderMode::verbose;
+      global.params.cxxhdr.fullOutput = true;
       break;
 
     case OPT_fdump_d_original:
@@ -572,18 +571,22 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
       global.params.useDIP25 = FeatureState::enabled;
       global.params.useDIP1000 = FeatureState::enabled;
       global.params.useDIP1021 = value;
+      global.params.bitfields = value;
       global.params.dtorFields = FeatureState::enabled;
       global.params.fieldwise = value;
       global.params.fixAliasThis = value;
       global.params.previewIn = value;
       global.params.fix16997 = value;
-      global.params.markdown = value;
       global.params.noSharedAccess = value;
       global.params.rvalueRefParam = FeatureState::enabled;
       global.params.inclusiveInContracts = value;
       global.params.shortenedMethods = value;
       break;
 
+    case OPT_fpreview_bitfields:
+      global.params.bitfields = value;
+      break;
+
     case OPT_fpreview_dip1000:
       global.params.useDIP1000 = FeatureState::enabled;
       break;
@@ -641,7 +644,6 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
       global.params.useDIP25 = FeatureState::disabled;
       global.params.dtorFields = FeatureState::disabled;
       global.params.fix16997 = !value;
-      global.params.markdown = !value;
       break;
 
     case OPT_frevert_dip1000:
@@ -660,17 +662,14 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
       global.params.fix16997 = !value;
       break;
 
-    case OPT_frevert_markdown:
-      global.params.markdown = !value;
-      break;
-
     case OPT_frtti:
       global.params.useTypeInfo = value;
       break;
 
     case OPT_fsave_mixins_:
-      global.params.mixinFile = arg;
-      global.params.mixinOut = d_gc_malloc<OutBuffer> ();
+      global.params.mixinOut.doOutput = true;
+      global.params.mixinOut.name = arg;
+      global.params.mixinOut.buffer = d_gc_malloc<OutBuffer> ();
       break;
 
     case OPT_fswitch_errors:
@@ -681,7 +680,6 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
       global.params.vfield = value;
       global.params.vgc = value;
       global.params.vin = value;
-      global.params.vmarkdown= value;
       global.params.vtls = value;
       break;
 
@@ -697,10 +695,6 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
       global.params.vgc = value;
       break;
 
-    case OPT_ftransition_vmarkdown:
-      global.params.vmarkdown = value;
-      break;
-
     case OPT_ftransition_templates:
       global.params.vtemplates = value;
       break;
@@ -736,17 +730,17 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
       break;
 
     case OPT_H:
-      global.params.doHdrGeneration = true;
+      global.params.dihdr.doOutput = true;
       break;
 
     case OPT_Hd:
-      global.params.doHdrGeneration = true;
-      global.params.hdrdir = arg;
+      global.params.dihdr.doOutput = true;
+      global.params.dihdr.dir = arg;
       break;
 
     case OPT_Hf:
-      global.params.doHdrGeneration = true;
-      global.params.hdrname = arg;
+      global.params.dihdr.doOutput = true;
+      global.params.dihdr.name = arg;
       break;
 
     case OPT_imultilib:
@@ -827,11 +821,11 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
       break;
 
     case OPT_Xf:
-      global.params.jsonfilename = arg;
+      global.params.json.name = arg;
       /* Fall through.  */
 
     case OPT_X:
-      global.params.doJsonGeneration = true;
+      global.params.json.doOutput = true;
       break;
 
     default:
@@ -904,16 +898,26 @@ d_post_options (const char ** fn)
        ? CHECKENABLEoff : CHECKENABLEon;
     }
 
+  /* When not linking against D runtime, turn off all code generation that
+     would otherwise reference it.  */
   if (global.params.betterC)
     {
       if (!OPTION_SET_P (flag_moduleinfo))
        global.params.useModuleInfo = false;
 
+      /* Ensure that the front-end options are in sync with the `-frtti' and
+        `-fexceptions' flags.  */
       if (!OPTION_SET_P (flag_rtti))
-       global.params.useTypeInfo = false;
+       {
+         global.params.useTypeInfo = false;
+         flag_rtti = false;
+       }
 
       if (!OPTION_SET_P (flag_exceptions))
-       global.params.useExceptions = false;
+       {
+         global.params.useExceptions = false;
+         flag_exceptions = false;
+       }
 
       global.params.checkAction = CHECKACTION_C;
     }
@@ -947,19 +951,15 @@ d_post_options (const char ** fn)
   if (flag_excess_precision == EXCESS_PRECISION_DEFAULT)
     flag_excess_precision = EXCESS_PRECISION_STANDARD;
 
-  global.params.symdebug = write_symbols != NO_DEBUG;
   global.params.useInline = flag_inline_functions;
   global.params.showColumns = flag_show_column;
   global.params.printErrorContext = flag_diagnostics_show_caret;
 
   if (global.params.useInline)
-    global.params.hdrStripPlainFunctions = false;
+    global.params.dihdr.fullOutput = true;
 
   global.params.obj = !flag_syntax_only;
 
-  /* Has no effect yet.  */
-  global.params.pic = flag_pic != 0;
-
   /* Add in versions given on the command line.  */
   if (global.params.versionids)
     {
@@ -1068,8 +1068,8 @@ d_parse_file (void)
          /* Handling stdin, generate a unique name for the module.  */
          Module *m = Module::create (in_fnames[i],
                                      Identifier::idPool ("__stdin"),
-                                     global.params.doDocComments,
-                                     global.params.doHdrGeneration);
+                                     global.params.ddoc.doOutput,
+                                     global.params.dihdr.doOutput);
          modules.push (m);
 
          /* Overwrite the source file for the module, the one created by
@@ -1084,8 +1084,8 @@ d_parse_file (void)
          const char *name = FileName::removeExt (basename);
 
          Module *m = Module::create (in_fnames[i], Identifier::idPool (name),
-                                     global.params.doDocComments,
-                                     global.params.doHdrGeneration);
+                                     global.params.ddoc.doOutput,
+                                     global.params.dihdr.doOutput);
          modules.push (m);
          FileName::free (name);
        }
@@ -1142,7 +1142,7 @@ d_parse_file (void)
   if (global.errors)
     goto had_errors;
 
-  if (global.params.doHdrGeneration)
+  if (global.params.dihdr.doOutput)
     {
       /* Generate 'header' import files.  Since 'header' import files must be
         independent of command line switches and what else is imported, they
@@ -1316,12 +1316,12 @@ d_parse_file (void)
     printTemplateStats ();
 
   /* Generate JSON files.  */
-  if (global.params.doJsonGeneration)
+  if (global.params.json.doOutput)
     {
       OutBuffer buf;
       json_generate (&buf, &modules);
 
-      const char *name = global.params.jsonfilename.ptr;
+      const char *name = global.params.json.name.ptr;
       FILE *json_stream;
 
       if (name && (name[0] != '-' || name[1] != '\0'))
@@ -1346,7 +1346,7 @@ d_parse_file (void)
     }
 
   /* Generate Ddoc files.  */
-  if (global.params.doDocComments && !global.errors && !errorcount)
+  if (global.params.ddoc.doOutput && !global.errors && !errorcount)
     {
       for (size_t i = 0; i < modules.length; i++)
        {
@@ -1370,7 +1370,7 @@ d_parse_file (void)
     }
 
   /* Generate C++ header files.  */
-  if (global.params.doCxxHdrGeneration != CxxHeaderMode::none)
+  if (global.params.cxxhdr.doOutput)
     genCppHdrFiles (modules);
 
   if (global.errors)
@@ -1403,23 +1403,23 @@ d_parse_file (void)
   errorcount += (global.errors + global.warnings);
 
   /* We want to write the mixin expansion file also on error.  */
-  if (global.params.mixinOut)
+  if (global.params.mixinOut.doOutput)
     {
-      FILE *mixin_stream = fopen (global.params.mixinFile, "w");
+      FILE *mixin_stream = fopen (global.params.mixinOut.name.ptr, "w");
 
       if (mixin_stream)
        {
-         OutBuffer *buf = global.params.mixinOut;
+         OutBuffer *buf = global.params.mixinOut.buffer;
          fprintf (mixin_stream, "%s", buf->peekChars ());
 
          if (ferror (mixin_stream) || fclose (mixin_stream))
            fatal_error (input_location, "closing mixin file %s: %m",
-                        global.params.mixinFile);
+                        global.params.mixinOut.name.ptr);
        }
       else
        {
          fatal_error (input_location, "opening mixin file %s: %m",
-                      global.params.mixinFile);
+                      global.params.mixinOut.name.ptr);
        }
     }
 
@@ -1558,7 +1558,7 @@ d_type_promotes_to (tree type)
   /* Promotions are only applied on unnamed function arguments for declarations
      with `extern(C)' or `extern(C++)' linkage.  */
   if (cfun && DECL_LANG_FRONTEND (cfun->decl)
-      && DECL_LANG_FRONTEND (cfun->decl)->linkage != LINK::d)
+      && DECL_LANG_FRONTEND (cfun->decl)->resolvedLinkage () != LINK::d)
     {
       /* In [type/integer-promotions], integer promotions are conversions of the
         following types:
index 86ea1761f4f53eb6c23f48f9f411b2b2d1f9e5a7..f5c21078aadd74d265cd78725d62d0583a1a3b4d 100644 (file)
@@ -1845,7 +1845,7 @@ make_thunk (FuncDeclaration *decl, int offset)
      forcing a D local thunk to be emitted.  */
   const char *ident;
 
-  if (decl->linkage == LINK::cpp)
+  if (decl->resolvedLinkage () == LINK::cpp)
     ident = target.cpp.thunkMangle (decl, offset);
   else
     {
@@ -1862,7 +1862,7 @@ make_thunk (FuncDeclaration *decl, int offset)
 
   d_keep (thunk);
 
-  if (decl->linkage != LINK::cpp)
+  if (decl->resolvedLinkage () != LINK::cpp)
     free (CONST_CAST (char *, ident));
 
   if (!DECL_EXTERNAL (function))
index d18119193d4639fa3c9c74029f9f7011f5996fa1..b4d42ec6d2bba34706dd2c07ffc6c5cd85d45779 100644 (file)
@@ -1,4 +1,4 @@
-313d28b3db7523e67880ae3baf8ef28ce9abe9bd
+a6c5224b2d6b61fa3856aa8a3369581f7c949b68
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
index b14310312cda575a4d9339d72e25edc43151be5e..50c5ac3839151e92778ba5ce0112b31dfe15c8ff 100644 (file)
@@ -164,20 +164,21 @@ Note that these groups have no strict meaning, the category assignments are a bi
 
 **Other**
 
-| File                                                                          | Purpose                                                                                     |
-|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
-| [aliasthis.d](https://github.com/dlang/dmd/blob/master/src/dmd/aliasthis.d)   | Resolve implicit conversions for `alias X this`                                             |
-| [traits.d](https://github.com/dlang/dmd/blob/master/src/dmd/traits.d)         | `__traits()`                                                                                |
-| [lambdacomp.d](https://github.com/dlang/dmd/blob/master/src/dmd/lambdacomp.d) | `__traits(isSame, x => y, z => w)`                                                          |
-| [cond.d](https://github.com/dlang/dmd/blob/master/src/dmd/cond.d)             | Evaluate `static if`, `version` `debug `                                                    |
-| [staticcond.d](https://github.com/dlang/dmd/blob/master/src/dmd/staticcond.d) | Lazily evaluate static conditions for `static if`, `static assert` and template constraints |
-| [delegatize.d](https://github.com/dlang/dmd/blob/master/src/dmd/delegatize.d) | Converts expression to delegates for `lazy` parameters                                      |
-| [eh.d](https://github.com/dlang/dmd/blob/master/src/dmd/eh.d)                 | Generate tables for exception handling                                                      |
-| [nspace.d](https://github.com/dlang/dmd/blob/master/src/dmd/nspace.d)         | Namespace for `extern (C++, Module)`                                                        |
-| [intrange.d](https://github.com/dlang/dmd/blob/master/src/dmd/intrange.d)     | [Value range propagation](https://digitalmars.com/articles/b62.html)                        |
-| [dimport.d](https://github.com/dlang/dmd/blob/master/src/dmd/dimport.d)       | Renamed imports (`import aliasSymbol = pkg1.pkg2.symbol`)                                   |
-| [arrayop.d](https://github.com/dlang/dmd/blob/master/src/dmd/arrayop.d)       | Array operations (`a[] = b[] + c[]`)                                                        |
-| [typinf.d](https://github.com/dlang/dmd/blob/master/src/dmd/typinf.d)         | Generate typeinfo for `typeid()` (as well as internals)                                     |
+| File                                                                           | Purpose                                                                                     |
+|--------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
+| [aliasthis.d](https://github.com/dlang/dmd/blob/master/src/dmd/aliasthis.d)    | Resolve implicit conversions for `alias X this`                                             |
+| [traits.d](https://github.com/dlang/dmd/blob/master/src/dmd/traits.d)          | `__traits()`                                                                                |
+| [lambdacomp.d](https://github.com/dlang/dmd/blob/master/src/dmd/lambdacomp.d)  | `__traits(isSame, x => y, z => w)`                                                          |
+| [cond.d](https://github.com/dlang/dmd/blob/master/src/dmd/cond.d)              | Evaluate `static if`, `version` `debug `                                                    |
+| [staticcond.d](https://github.com/dlang/dmd/blob/master/src/dmd/staticcond.d)  | Lazily evaluate static conditions for `static if`, `static assert` and template constraints |
+| [delegatize.d](https://github.com/dlang/dmd/blob/master/src/dmd/delegatize.d)  | Converts expression to delegates for `lazy` parameters                                      |
+| [eh.d](https://github.com/dlang/dmd/blob/master/src/dmd/eh.d)                  | Generate tables for exception handling                                                      |
+| [nspace.d](https://github.com/dlang/dmd/blob/master/src/dmd/nspace.d)          | Namespace for `extern (C++, Module)`                                                        |
+| [intrange.d](https://github.com/dlang/dmd/blob/master/src/dmd/intrange.d)      | [Value range propagation](https://digitalmars.com/articles/b62.html)                        |
+| [dimport.d](https://github.com/dlang/dmd/blob/master/src/dmd/dimport.d)        | Renamed imports (`import aliasSymbol = pkg1.pkg2.symbol`)                                   |
+| [arrayop.d](https://github.com/dlang/dmd/blob/master/src/dmd/arrayop.d)        | Array operations (`a[] = b[] + c[]`)                                                        |
+| [cpreprocess.d](https://github.com/dlang/dmd/blob/master/src/dmd/cpreprocess.d)| Run the C preprocessor on C source files                                                   |
+| [typinf.d](https://github.com/dlang/dmd/blob/master/src/dmd/typinf.d)          | Generate typeinfo for `typeid()` (as well as internals)                                     |
 
 | File                                                                        | Purpose                                                                            |
 |-----------------------------------------------------------------------------|------------------------------------------------------------------------------------|
index 2450fd55ef8be70d7ae4b3d6b040dfd58b89bca4..5ea2ba0d8ec1559a41c1e14d714a5f994ff65570 100644 (file)
@@ -1 +1 @@
-v2.100.0-beta.1
+v2.100.0
index 9c8c1c316bff7f2c09f04c4d8271dd3506117338..75a16bd2da4d25217fb7a08eec07b427e2ea5602 100644 (file)
@@ -563,9 +563,12 @@ FuncDeclaration buildXopEquals(StructDeclaration sd, Scope* sc)
         e = new DotIdExp(sd.loc, e, Id.object);
         e = new DotIdExp(sd.loc, e, id);
         e = e.expressionSemantic(sc);
-        Dsymbol s = getDsymbol(e);
-        assert(s);
-        sd.xerreq = s.isFuncDeclaration();
+        if (!e.isErrorExp())
+        {
+            Dsymbol s = getDsymbol(e);
+            assert(s);
+            sd.xerreq = s.isFuncDeclaration();
+        }
     }
     Loc declLoc; // loc is unnecessary so __xopEquals is never called directly
     Loc loc; // loc is unnecessary so errors are gagged
@@ -684,9 +687,12 @@ FuncDeclaration buildXopCmp(StructDeclaration sd, Scope* sc)
         e = new DotIdExp(sd.loc, e, Id.object);
         e = new DotIdExp(sd.loc, e, id);
         e = e.expressionSemantic(sc);
-        Dsymbol s = getDsymbol(e);
-        assert(s);
-        sd.xerrcmp = s.isFuncDeclaration();
+        if (!e.isErrorExp())
+        {
+            Dsymbol s = getDsymbol(e);
+            assert(s);
+            sd.xerrcmp = s.isFuncDeclaration();
+        }
     }
     Loc declLoc; // loc is unnecessary so __xopCmp is never called directly
     Loc loc; // loc is unnecessary so errors are gagged
@@ -867,7 +873,7 @@ void buildDtors(AggregateDeclaration ad, Scope* sc)
 
     // Build the field destructor (`ad.fieldDtor`), if needed.
     // If the user dtor is an extern(C++) prototype, then we expect it performs a full-destruction and skip building.
-    const bool dtorIsCppPrototype = ad.userDtors.dim && ad.userDtors[0].linkage == LINK.cpp && !ad.userDtors[0].fbody;
+    const bool dtorIsCppPrototype = ad.userDtors.dim && ad.userDtors[0]._linkage == LINK.cpp && !ad.userDtors[0].fbody;
     if (!dtorIsCppPrototype)
     {
         Expression e = null;
@@ -1019,7 +1025,7 @@ void buildDtors(AggregateDeclaration ad, Scope* sc)
 
     // Set/build `ad.dtor`.
     // On Windows, the dtor in the vtable is a shim with different signature.
-    ad.dtor = (ad.aggrDtor && ad.aggrDtor.linkage == LINK.cpp && !target.cpp.twoDtorInVtable)
+    ad.dtor = (ad.aggrDtor && ad.aggrDtor._linkage == LINK.cpp && !target.cpp.twoDtorInVtable)
         ? buildWindowsCppDtor(ad, ad.aggrDtor, sc)
         : ad.aggrDtor;
 
index d17983d66b4416c674e0ff30653b44e273b97e49..cccaabd6d679d9de3bdaa4d6fdb53300d682657f 100644 (file)
@@ -30,7 +30,7 @@ if (__traits(isUnsigned, T))
         enum mask = "(1 << "~i.stringof~")";
         result ~= "
         /// set or get the corresponding "~structName~" member
-        bool "~mem~"() const { return !!(bitFields & "~mask~"); }
+        bool "~mem~"() const scope { return !!(bitFields & "~mask~"); }
         /// ditto
         bool "~mem~"(bool v)
         {
index 7e46d294f3d3d4dd807261dc95ff93d343a8d3cb..9a5bd822384ae7939315f58cb0b63e18762edcaa 100644 (file)
@@ -309,23 +309,24 @@ struct OutBuffer
         writenl();
     }
 
-    // Zero-terminated
-    void writeString(const(char)* s) pure nothrow @trusted
+    /** Write string to buffer, ensure it is zero terminated
+     */
+    void writeStringz(const(char)* s) pure nothrow @trusted
     {
         write(s[0 .. strlen(s)+1]);
     }
 
     /// ditto
-    void writeString(const(char)[] s) pure nothrow
+    void writeStringz(const(char)[] s) pure nothrow
     {
         write(s);
         writeByte(0);
     }
 
     /// ditto
-    void writeString(string s) pure nothrow
+    void writeStringz(string s) pure nothrow
     {
-        writeString(cast(const(char)[])(s));
+        writeStringz(cast(const(char)[])(s));
     }
 
     extern (C++) void prependstring(const(char)* string) pure nothrow
index dee0a1795749656fa7db8d55bfecd1582ef18d53..65085f544f7486e83b7c2630374be167095b5400 100644 (file)
@@ -370,7 +370,7 @@ extern (C++) final class StaticForeach : RootObject
         Type ety = new TypeTypeof(aloc, wrapAndCall(aloc, new CompoundStatement(aloc, s1)));
         auto aty = ety.arrayOf();
         auto idres = Identifier.generateId("__res");
-        auto vard = new VarDeclaration(aloc, aty, idres, null);
+        auto vard = new VarDeclaration(aloc, aty, idres, null, STC.temp);
         auto s2 = new Statements();
 
         // Run 'typeof' gagged to avoid duplicate errors and if it fails just create
@@ -984,9 +984,9 @@ bool findCondition(Identifiers* ids, Identifier ident) @safe nothrow pure
 // Helper for printing dependency information
 private void printDepsConditional(Scope* sc, DVCondition condition, const(char)[] depType)
 {
-    if (!global.params.moduleDeps || global.params.moduleDepsFile)
+    if (!global.params.moduleDeps.buffer || global.params.moduleDeps.name)
         return;
-    OutBuffer* ob = global.params.moduleDeps;
+    OutBuffer* ob = global.params.moduleDeps.buffer;
     Module imod = sc ? sc._module : condition.mod;
     if (!imod)
         return;
index bf66408f1d4e69d362fcf56a2017eaad81b8b2bf..d90542f3fd83f77f68a7300bebde444d57bc8b01 100644 (file)
@@ -1181,7 +1181,7 @@ UnionExp Cast(const ref Loc loc, Type type, Type to, Expression e1)
     {
         if (type != Type.terror)
         {
-            // have to change to Internal Compiler Error
+            // have to change to internal compiler error
             // all invalid casts should be handled already in Expression::castTo().
             error(loc, "cannot cast `%s` to `%s`", e1.type.toChars(), type.toChars());
         }
index 2b2046f3da30277a1431ce60fd0893bdecb0b9e5..fde064843704157514e30f9da1fd5b63409b8c34 100644 (file)
@@ -284,6 +284,7 @@ final class CParser(AST) : Parser!AST
         case TOK.struct_:
         case TOK.union_:
         case TOK.enum_:
+        case TOK.typeof_:
 
         // storage-class-specifiers
         case TOK.typedef_:
@@ -1662,6 +1663,14 @@ final class CParser(AST) : Parser!AST
             return;
         }
 
+        if (!tspec)
+        {
+            error("no type for declarator before `%s`", token.toChars());
+            panic();
+            nextToken();
+            return;
+        }
+
         if (tspec && specifier.mod & MOD.xconst)
         {
             tspec = toConst(tspec);
@@ -2287,6 +2296,52 @@ final class CParser(AST) : Parser!AST
                     break;
                 }
 
+                case TOK.typeof_:
+                {
+                    nextToken();
+                    check(TOK.leftParenthesis);
+
+                    auto tk = &token;
+                    AST.Expression e;
+                    if (isTypeName(tk))
+                        e = new AST.TypeExp(loc, cparseTypeName());
+                    else
+                        e = cparseExpression();
+                    t = new AST.TypeTypeof(loc, e);
+
+                    if(token.value == TOK.rightParenthesis)
+                        nextToken();
+                    else
+                    {
+                        t = AST.Type.terror;
+                        error("`typeof` operator expects an expression or type name in parentheses");
+
+                        // skipParens et. al expect to be on the opening parenthesis
+                        int parens;
+                        loop: while(1)
+                        {
+                            switch(token.value)
+                            {
+                                case TOK.leftParenthesis:
+                                    parens++;
+                                    break;
+                                case TOK.rightParenthesis:
+                                    parens--;
+                                    if(parens < 0)
+                                        goto case;
+                                    break;
+                                case TOK.endOfFile:
+                                    break loop;
+                                default:
+                            }
+                            nextToken();
+                        }
+                    }
+
+                    tkwx = TKW.xtag;
+                    break;
+                }
+
                 default:
                     break Lwhile;
             }
@@ -2498,7 +2553,7 @@ final class CParser(AST) : Parser!AST
     private AST.Type cparseDeclarator(DTR declarator, AST.Type t,
         out Identifier pident, ref Specifier specifier)
     {
-        //printf("cparseDeclarator(%d)\n", declarator);
+        //printf("cparseDeclarator(%d, %p)\n", declarator, t);
         AST.Types constTypes; // all the Types that will need `const` applied to them
         constTypes.setDim(0);
 
@@ -4227,6 +4282,7 @@ final class CParser(AST) : Parser!AST
 
                 // atomic-type-specifier
                 case TOK._Atomic:
+                case TOK.typeof_:
                     t = peek(t);
                     if (t.value != TOK.leftParenthesis ||
                         !skipParens(t, &t))
index 13ef34c052b1379b233c47b42aa9ccedb27f2e76..6235342a4f4c8068d53118399059950381dac12f 100644 (file)
@@ -471,7 +471,7 @@ private final class CppMangleVisitor : Visitor
             }
             else
             {
-                ti.error("Internal Compiler Error: C++ `%s` template value parameter is not supported", tv.valType.toChars());
+                ti.error("internal compiler error: C++ `%s` template value parameter is not supported", tv.valType.toChars());
                 fatal();
             }
         }
@@ -506,13 +506,13 @@ private final class CppMangleVisitor : Visitor
             }
             else
             {
-                ti.error("Internal Compiler Error: C++ `%s` template alias parameter is not supported", o.toChars());
+                ti.error("internal compiler error: C++ `%s` template alias parameter is not supported", o.toChars());
                 fatal();
             }
         }
         else if (tp.isTemplateThisParameter())
         {
-            ti.error("Internal Compiler Error: C++ `%s` template this parameter is not supported", o.toChars());
+            ti.error("internal compiler error: C++ `%s` template this parameter is not supported", o.toChars());
             fatal();
         }
         else
@@ -995,7 +995,7 @@ private final class CppMangleVisitor : Visitor
         // fake mangling for fields to fix https://issues.dlang.org/show_bug.cgi?id=16525
         if (!(d.storage_class & (STC.extern_ | STC.field | STC.gshared)))
         {
-            d.error("Internal Compiler Error: C++ static non-`__gshared` non-`extern` variables not supported");
+            d.error("internal compiler error: C++ static non-`__gshared` non-`extern` variables not supported");
             fatal();
         }
         Dsymbol p = d.toParent();
@@ -1330,7 +1330,7 @@ private final class CppMangleVisitor : Visitor
             if (t.ty == Tsarray)
             {
                 // Static arrays in D are passed by value; no counterpart in C++
-                .error(loc, "Internal Compiler Error: unable to pass static array `%s` to extern(C++) function, use pointer instead",
+                .error(loc, "internal compiler error: unable to pass static array `%s` to extern(C++) function, use pointer instead",
                     t.toChars());
                 fatal();
             }
@@ -1369,7 +1369,7 @@ private final class CppMangleVisitor : Visitor
             p = "`shared` ";
         else
             p = "";
-        .error(loc, "Internal Compiler Error: %stype `%s` cannot be mapped to C++\n", p, t.toChars());
+        .error(loc, "internal compiler error: %stype `%s` cannot be mapped to C++\n", p, t.toChars());
         fatal(); //Fatal, because this error should be handled in frontend
     }
 
index 83978391e42657c60977eb73c880bc6c075a5d01..c0a86f57dd245d71b5a2a97835972792e728ead1 100644 (file)
@@ -1695,14 +1695,6 @@ Expression castTo(Expression e, Scope* sc, Type t, Type att = null)
             {
                 // T[n] sa;
                 // cast(U[])sa; // ==> cast(U[])sa[];
-                if (global.params.useDIP1000 == FeatureState.enabled)
-                {
-                    if (auto v = expToVariable(e))
-                    {
-                        if (e.type.hasPointers() && !checkAddressVar(sc, e, v))
-                            goto Lfail;
-                    }
-                }
                 const fsize = t1b.nextOf().size();
                 const tsize = tob.nextOf().size();
                 if (fsize == SIZE_INVALID || tsize == SIZE_INVALID)
@@ -2236,7 +2228,7 @@ Expression castTo(Expression e, Scope* sc, Type t, Type att = null)
         ArrayLiteralExp ae = e;
 
         Type tb = t.toBasetype();
-        if (tb.ty == Tarray && global.params.useDIP1000 == FeatureState.enabled)
+        if (tb.ty == Tarray)
         {
             if (checkArrayLiteralEscape(sc, ae, false))
             {
@@ -2782,9 +2774,8 @@ Expression scaleFactor(BinExp be, Scope* sc)
         if (eoff.op == EXP.int64 && eoff.toInteger() == 0)
         {
         }
-        else if (sc.func.setUnsafe())
+        else if (sc.func.setUnsafe(false, be.loc, "pointer arithmetic not allowed in @safe functions"))
         {
-            be.error("pointer arithmetic not allowed in @safe functions");
             return ErrorExp.get();
         }
     }
index 15ac8d917351db6e987f897069497df380189bc6..a4a2abf4144be829d781c69f24c5f3b323e9d83b 100644 (file)
@@ -984,7 +984,7 @@ extern (C++) class ClassDeclaration : AggregateDeclaration
             auto var = new VarDeclaration(loc, vtype, Identifier.idPool("__vtbl"), null, STC.immutable_ | STC.static_);
             var.addMember(null, this);
             var.isdataseg = 1;
-            var.linkage = LINK.d;
+            var._linkage = LINK.d;
             var.semanticRun = PASS.semanticdone; // no more semantic wanted
             vtblsym = var;
         }
index a533d30ca808353f93dc78a8184a7d6e5ef77b02..bb0feb642bdcece427ffffe6586f38d68a2f8738 100644 (file)
@@ -221,7 +221,7 @@ extern (C++) abstract class Declaration : Dsymbol
     Type originalType;  // before semantic analysis
     StorageClass storage_class = STC.undefined_;
     Visibility visibility;
-    LINK linkage = LINK.default_;
+    LINK _linkage = LINK.default_; // may be `LINK.system`; use `resolvedLinkage()` to resolve it
     short inuse;          // used to detect cycles
 
     ubyte adFlags;         // control re-assignment of AliasDeclaration (put here for packing reasons)
@@ -336,7 +336,7 @@ extern (C++) abstract class Declaration : Dsymbol
         {
             if (ctor.isCpCtor && ctor.isGenerated())
             {
-                .error(loc, "Generating an `inout` copy constructor for `struct %s` failed, therefore instances of it are uncopyable", parent.toPrettyChars());
+                .error(loc, "generating an `inout` copy constructor for `struct %s` failed, therefore instances of it are uncopyable", parent.toPrettyChars());
                 return true;
             }
         }
@@ -420,6 +420,12 @@ extern (C++) abstract class Declaration : Dsymbol
         return (storage_class & STC.static_) != 0;
     }
 
+    /// Returns the linkage, resolving the target-specific `System` one.
+    final LINK resolvedLinkage() const
+    {
+        return _linkage == LINK.system ? target.systemLinkage() : _linkage;
+    }
+
     bool isDelete()
     {
         return false;
@@ -1506,7 +1512,7 @@ extern (C++) class VarDeclaration : Declaration
         uint oldgag = global.gag;
         if (global.gag)
         {
-            Dsymbol sym = toParent().isAggregateDeclaration();
+            Dsymbol sym = isMember();
             if (sym && !sym.isSpeculative())
                 global.gag = 0;
         }
@@ -1691,6 +1697,32 @@ extern (C++) class BitFieldDeclaration : VarDeclaration
         v.visit(this);
     }
 
+    /***********************************
+     * Retrieve the .min or .max values.
+     * Only valid after semantic analysis.
+     * Params:
+     *  id = Id.min or Id.max
+     * Returns:
+     *  the min or max value
+     */
+    final ulong getMinMax(Identifier id)
+    {
+        const width = fieldWidth;
+        const uns = type.isunsigned();
+        const min = id == Id.min;
+        ulong v;
+        assert(width != 0);  // should have been rejected in semantic pass
+        if (width == ulong.sizeof * 8)
+            v = uns ? (min ? ulong.min : ulong.max)
+                    : (min ?  long.min :  long.max);
+        else
+            v = uns ? (min ? 0
+                           : (1L << width) - 1)
+                    : (min ? -(1L << (width - 1))
+                           :  (1L << (width - 1)) - 1);
+        return v;
+    }
+
     override final void setFieldOffset(AggregateDeclaration ad, ref FieldState fieldState, bool isunion)
     {
         //printf("BitFieldDeclaration::setFieldOffset(ad: %s, field: %s)\n", ad.toChars(), toChars());
@@ -1919,7 +1951,7 @@ extern (C++) class TypeInfoDeclaration : VarDeclaration
         this.tinfo = tinfo;
         storage_class = STC.static_ | STC.gshared;
         visibility = Visibility(Visibility.Kind.public_);
-        linkage = LINK.c;
+        _linkage = LINK.c;
         alignment.set(target.ptrsize);
     }
 
index 441a966cf4d21295bc38546976430d5fbbc014fd..0bde33dd9e97e11c7e3b1b84cbb1c7576eb0ba43 100644 (file)
@@ -28,6 +28,7 @@ struct Ensure
 class FuncDeclaration;
 class StructDeclaration;
 struct IntRange;
+struct AttributeViolation;
 
 //enum STC : ulong from astenums.d:
 
@@ -115,7 +116,7 @@ public:
     Type *originalType;         // before semantic analysis
     StorageClass storage_class;
     Visibility visibility;
-    LINK linkage;
+    LINK _linkage;              // may be `LINK::system`; use `resolvedLinkage()` to resolve it
     short inuse;                // used to detect cycles
     uint8_t adFlags;
     Symbol* isym;               // import version of csym
@@ -127,6 +128,7 @@ public:
     Dsymbol *search(const Loc &loc, Identifier *ident, int flags = SearchLocalsOnly);
 
     bool isStatic() const { return (storage_class & STCstatic) != 0; }
+    LINK resolvedLinkage() const; // returns the linkage, resolving the target-specific `System` one
     virtual bool isDelete();
     virtual bool isDataseg();
     virtual bool isThreadlocal();
@@ -612,6 +614,10 @@ public:
 
     FuncDeclarations *inlinedNestedCallees;
 
+private:
+    AttributeViolation* safetyViolation;
+public:
+
     unsigned flags;                     // FUNCFLAGxxxxx
 
     // Data for a function declaration that is needed for the Objective-C
@@ -655,6 +661,7 @@ public:
     bool isNRVO() const;
     void isNRVO(bool v);
     bool isNaked() const;
+    void isNaked(bool v);
     bool isGenerated() const;
     void isGenerated(bool v);
     bool isIntroducing() const;
@@ -664,7 +671,9 @@ public:
     bool hasDualContext() const;
     bool hasAlwaysInlines() const;
     bool isCrtCtor() const;
+    void isCrtCtor(bool v);
     bool isCrtDtor() const;
+    void isCrtDtor(bool v);
 
     virtual bool isNested() const;
     AggregateDeclaration *isThis();
index 3cfc07ab9105a5104ede390609d7363c7734e9ef..5e7527d70414b097bdf6f0e4ab2dfdefdc86233b 100644 (file)
@@ -674,8 +674,20 @@ private Expression interpretFunction(UnionExp* pue, FuncDeclaration fd, InterSta
         }
     }
     // If fell off the end of a void function, return void
-    if (!e && tf.next.ty == Tvoid)
-        e = CTFEExp.voidexp;
+    if (!e)
+    {
+        if (tf.next.ty == Tvoid)
+            e = CTFEExp.voidexp;
+        else
+        {
+            /* missing a return statement can happen with C functions
+             * https://issues.dlang.org/show_bug.cgi?id=23056
+             */
+            fd.error("no return value from function");
+            e = CTFEExp.cantexp;
+        }
+    }
+
     if (tf.isref && e.op == EXP.variable && e.isVarExp().var == fd.vthis)
         e = thisarg;
     if (tf.isref && fd.hasDualContext() && e.op == EXP.index)
@@ -695,7 +707,6 @@ private Expression interpretFunction(UnionExp* pue, FuncDeclaration fd, InterSta
             }
         }
     }
-    assert(e !is null);
 
     // Leave the function
     --ctfeGlobals.callDepth;
@@ -1038,6 +1049,21 @@ public:
         if (exceptionOrCant(e))
             return;
 
+        /**
+         * Interpret `return a ~= b` (i.e. `return _d_arrayappendT{,Trace}(a, b)`) as:
+         *     a ~= b;
+         *     return a;
+         * This is needed because `a ~= b` has to be interpreted as an lvalue, in order to avoid
+         * assigning a larger array into a smaller one, such as:
+         *    `a = [1, 2], a ~= [3]` => `[1, 2] ~= [3]` => `[1, 2] = [1, 2, 3]`
+         */
+        if (isRuntimeHook(s.exp, Id._d_arrayappendT) || isRuntimeHook(s.exp, Id._d_arrayappendTTrace))
+        {
+            auto rs = new ReturnStatement(s.loc, e);
+            rs.accept(this);
+            return;
+        }
+
         // Disallow returning pointers to stack-allocated variables (bug 7876)
         if (!stopPointersEscaping(s.loc, e))
         {
@@ -4826,6 +4852,33 @@ public:
                 result = interpret(ce, istate);
                 return;
             }
+            else if (fd.ident == Id._d_arrayappendT || fd.ident == Id._d_arrayappendTTrace)
+            {
+                // In expressionsem.d `ea ~= eb` was lowered to `_d_arrayappendT{,Trace}({file, line, funcname}, ea, eb);`.
+                // The following code will rewrite it back to `ea ~= eb` and then interpret that expression.
+                Expression lhs, rhs;
+
+                if (fd.ident == Id._d_arrayappendT)
+                {
+                    assert(e.arguments.dim == 2);
+                    lhs = (*e.arguments)[0];
+                    rhs = (*e.arguments)[1];
+                }
+                else
+                {
+                    assert(e.arguments.dim == 5);
+                    lhs = (*e.arguments)[3];
+                    rhs = (*e.arguments)[4];
+                }
+
+                auto cae = new CatAssignExp(e.loc, lhs, rhs);
+                cae.type = e.type;
+
+                result = interpretRegion(cae, istate, CTFEGoal.LValue);
+                return;
+            }
+            else if (fd.ident == Id._d_arrayappendcTX)
+                assert(0, "CTFE cannot interpret _d_arrayappendcTX!");
         }
         else if (auto soe = ecall.isSymOffExp())
         {
@@ -4947,6 +5000,25 @@ public:
             printf("%s CommaExp::interpret() %s\n", e.loc.toChars(), e.toChars());
         }
 
+        if (auto ce = isRuntimeHook(e.e1, Id._d_arrayappendcTX))
+        {
+            // In expressionsem.d `arr ~= elem` was lowered to
+            // `_d_arrayappendcTX(arr, elem), arr[arr.length - 1] = elem, elem;`.
+            // The following code will rewrite it back to `arr ~= elem`
+            // and then interpret that expression.
+            assert(ce.arguments.dim == 2);
+
+            auto arr = (*ce.arguments)[0];
+            auto elem = e.e2.isConstructExp().e2;
+            assert(elem);
+
+            auto cae = new CatAssignExp(e.loc, arr, elem);
+            cae.type = arr.type;
+
+            result = interpret(cae, istate);
+            return;
+        }
+
         // If it creates a variable, and there's no context for
         // the variable to be created in, we need to create one now.
         InterState istateComma;
@@ -6119,7 +6191,7 @@ public:
             return;
         }
 
-        if (result.isStringExp())
+        if (result.isStringExp() || result.isArrayLiteralExp())
             return;
 
         if (result.op != EXP.address)
@@ -6268,7 +6340,7 @@ public:
         result = (*se.elements)[i];
         if (!result)
         {
-            e.error("Internal Compiler Error: null field `%s`", v.toChars());
+            e.error("internal compiler error: null field `%s`", v.toChars());
             result = CTFEExp.cantexp;
             return;
         }
@@ -6359,6 +6431,33 @@ public:
     {
         assert(0); // This should never be interpreted
     }
+
+    /*********************************************
+     * Checks if the given expresion is a call to the runtime hook `id`.
+     * Params:
+     *    e = the expression to check
+     *    id = the identifier of the runtime hook
+     * Returns:
+     *    `e` cast to `CallExp` if it's the hook, `null` otherwise
+     */
+    private CallExp isRuntimeHook(Expression e, Identifier id)
+    {
+        if (auto ce = e.isCallExp())
+        {
+            if (auto ve = ce.e1.isVarExp())
+            {
+                if (auto fd = ve.var.isFuncDeclaration())
+                {
+                    // If `_d_HookTraceImpl` is found, resolve the underlying
+                    // hook and replace `e` and `fd` with it.
+                    removeHookTraceImpl(ce, fd);
+                    return fd.ident == id ? ce : null;
+                }
+            }
+        }
+
+        return null;
+    }
 }
 
 /********************************************
index 1f895e03af05eb66afba9e954b02ac4d73c7e64f..76042969b9b2542e53d1b07167d8e5717bae473a 100644 (file)
@@ -1335,15 +1335,19 @@ void realToMangleBuffer(OutBuffer* buf, real_t value)
 private
 extern (D) const(char)[] externallyMangledIdentifier(Declaration d)
 {
+    assert(!d.mangleOverride, "mangle overrides should have been handled earlier");
+
+    const linkage = d.resolvedLinkage();
     const par = d.toParent(); //toParent() skips over mixin templates
-    if (!par || par.isModule() || d.linkage == LINK.cpp ||
-        (d.linkage == LINK.c && d.isCsymbol() && d.isFuncDeclaration()))
+    if (!par || par.isModule() || linkage == LINK.cpp ||
+        (linkage == LINK.c && d.isCsymbol() &&
+         (d.isFuncDeclaration() ||
+          (d.isVarDeclaration() && d.isDataseg() && d.storage_class & STC.extern_))))
     {
-        if (d.linkage != LINK.d && d.localNum)
+        if (linkage != LINK.d && d.localNum)
             d.error("the same declaration cannot be in multiple scopes with non-D linkage");
 
-        const l = d.linkage == LINK.system ? target.systemLinkage() : d.linkage;
-        final switch (l)
+        final switch (linkage)
         {
             case LINK.d:
                 break;
index 2d9f6510ba5624e34f253522bfe7f528cbe68e7f..26a0ff03092d6407d317064f7709f827a54baef4 100644 (file)
@@ -71,7 +71,7 @@ void semantic3OnDependencies(Module m)
  */
 void removeHdrFilesAndFail(ref Param params, ref Modules modules) nothrow
 {
-    if (params.doHdrGeneration)
+    if (params.dihdr.doOutput)
     {
         foreach (m; modules)
         {
@@ -472,7 +472,7 @@ extern (C++) final class Module : Package
         if (doDocComment)
             setDocfile();
         if (doHdrGen)
-            hdrfile = setOutfilename(global.params.hdrname, global.params.hdrdir, arg, hdr_ext);
+            hdrfile = setOutfilename(global.params.dihdr.name, global.params.dihdr.dir, arg, hdr_ext);
     }
 
     extern (D) this(const(char)[] filename, Identifier ident, int doDocComment, int doHdrGen)
@@ -584,7 +584,7 @@ extern (C++) final class Module : Package
 
     extern (D) void setDocfile()
     {
-        docfile = setOutfilename(global.params.docname, global.params.docdir, arg, doc_ext);
+        docfile = setOutfilename(global.params.ddoc.name, global.params.ddoc.dir, arg, doc_ext);
     }
 
     /**
@@ -662,11 +662,55 @@ extern (C++) final class Module : Package
             return true; // already read
 
         //printf("Module::read('%s') file '%s'\n", toChars(), srcfile.toChars());
-        if (auto result = global.fileManager.lookup(srcfile))
+
+        /* Preprocess the file if it's a .c file
+         */
+        FileName filename = srcfile;
+        bool ifile = false;             // did we generate a .i file
+        scope (exit)
+        {
+            if (ifile)
+                File.remove(filename.toChars());        // remove generated file
+        }
+
+        if (global.preprocess &&
+            FileName.equalsExt(srcfile.toString(), c_ext) &&
+            FileName.exists(srcfile.toString()))
+        {
+            /* Look for "importc.h" by searching along import path.
+             * It should be in the same place as "object.d"
+             */
+            const(char)* importc_h;
+
+            foreach (entry; (global.path ? (*global.path)[] : null))
+            {
+                auto f = FileName.combine(entry, "importc.h");
+                if (FileName.exists(f) == 1)
+                {
+                     importc_h = f;
+                     break;
+                }
+                FileName.free(f);
+            }
+
+            if (importc_h)
+            {
+                if (global.params.verbose)
+                    message("include   %s", importc_h);
+            }
+            else
+            {
+                error("cannot find \"importc.h\" along import path");
+                fatal();
+            }
+            filename = global.preprocess(srcfile, importc_h, global.params.cppswitches, ifile);  // run C preprocessor
+        }
+
+        if (auto result = global.fileManager.lookup(filename))
         {
             this.src = result;
-            if (global.params.emitMakeDeps)
-                global.params.makeDeps.push(srcfile.toChars());
+            if (global.params.makeDeps.doOutput)
+                global.params.makeDeps.files.push(srcfile.toChars());
             return true;
         }
 
index d05060df045d4a3ff4769efee364aa76afe335da..6eb433e3d4a44558796856e5c75fe85e1b37adc3 100644 (file)
@@ -384,11 +384,11 @@ extern(C++) void gendocfile(Module m)
         // Override with DDOCFILE specified in the sc.ini file
         char* p = getenv("DDOCFILE");
         if (p)
-            global.params.ddocfiles.shift(p);
+            global.params.ddoc.files.shift(p);
         // Override with the ddoc macro files from the command line
-        for (size_t i = 0; i < global.params.ddocfiles.dim; i++)
+        for (size_t i = 0; i < global.params.ddoc.files.dim; i++)
         {
-            auto buffer = readFile(m.loc, global.params.ddocfiles[i]);
+            auto buffer = readFile(m.loc, global.params.ddoc.files[i]);
             // BUG: convert file contents to UTF-8 before use
             const data = buffer.data;
             //printf("file: '%.*s'\n", cast(int)data.length, data.ptr);
@@ -628,7 +628,7 @@ private void escapeStrayParenthesis(Loc loc, OutBuffer* buf, size_t start, bool
             break;
         case '\\':
             // replace backslash-escaped parens with their macros
-            if (!inCode && respectBackslashEscapes && u+1 < buf.length && global.params.markdown)
+            if (!inCode && respectBackslashEscapes && u+1 < buf.length)
             {
                 if ((*buf)[u+1] == '(' || (*buf)[u+1] == ')')
                 {
@@ -2317,8 +2317,6 @@ private void removeBlankLineMacro(ref OutBuffer buf, ref size_t iAt, ref size_t
  */
 private bool replaceMarkdownThematicBreak(ref OutBuffer buf, ref size_t i, size_t iLineStart, const ref Loc loc)
 {
-    if (!global.params.markdown)
-        return false;
 
     const slice = buf[];
     const c = buf[i];
@@ -2335,12 +2333,6 @@ private bool replaceMarkdownThematicBreak(ref OutBuffer buf, ref size_t i, size_
     {
         if (j >= buf.length || buf[j] == '\n' || buf[j] == '\r')
         {
-            if (global.params.vmarkdown)
-            {
-                const s = buf[][i..j];
-                message(loc, "Ddoc: converted '%.*s' to a thematic break", cast(int)s.length, s.ptr);
-            }
-
             buf.remove(iLineStart, j - iLineStart);
             i = buf.insert(iLineStart, "$(HR)") - 1;
             return true;
@@ -2361,9 +2353,6 @@ private bool replaceMarkdownThematicBreak(ref OutBuffer buf, ref size_t i, size_
  */
 private int detectAtxHeadingLevel(ref OutBuffer buf, const size_t i)
 {
-    if (!global.params.markdown)
-        return 0;
-
     const iHeadingStart = i;
     const iAfterHashes = skipChars(buf, i, "#");
     const headingLevel = cast(int) (iAfterHashes - iHeadingStart);
@@ -2433,14 +2422,6 @@ private void removeAnyAtxHeadingSuffix(ref OutBuffer buf, size_t i)
  */
 private void endMarkdownHeading(ref OutBuffer buf, size_t iStart, ref size_t iEnd, const ref Loc loc, ref int headingLevel)
 {
-    if (!global.params.markdown)
-        return;
-    if (global.params.vmarkdown)
-    {
-        const s = buf[][iStart..iEnd];
-        message(loc, "Ddoc: added heading '%.*s'", cast(int)s.length, s.ptr);
-    }
-
     char[5] heading = "$(H0 ";
     heading[3] = cast(char) ('0' + headingLevel);
     buf.insert(iStart, heading);
@@ -2503,9 +2484,6 @@ private size_t endAllListsAndQuotes(ref OutBuffer buf, ref size_t i, ref Markdow
  */
 private size_t replaceMarkdownEmphasis(ref OutBuffer buf, const ref Loc loc, ref MarkdownDelimiter[] inlineDelimiters, int downToLevel = 0)
 {
-    if (!global.params.markdown)
-        return 0;
-
     size_t replaceEmphasisPair(ref MarkdownDelimiter start, ref MarkdownDelimiter end)
     {
         immutable count = start.count == 1 || end.count == 1 ? 1 : 2;
@@ -2521,12 +2499,6 @@ private size_t replaceMarkdownEmphasis(ref OutBuffer buf, const ref Loc loc, ref
         if (!end.count)
             end.type = 0;
 
-        if (global.params.vmarkdown)
-        {
-            const s = buf[][iStart + count..iEnd];
-            message(loc, "Ddoc: emphasized text '%.*s'", cast(int)s.length, s.ptr);
-        }
-
         buf.remove(iStart, count);
         iEnd -= count;
         buf.remove(iEnd, count);
@@ -2857,9 +2829,6 @@ private struct MarkdownList
      */
     static MarkdownList parseItem(ref OutBuffer buf, size_t iLineStart, size_t i)
     {
-        if (!global.params.markdown)
-            return MarkdownList();
-
         if (buf[i] == '+' || buf[i] == '-' || buf[i] == '*')
             return parseUnorderedListItem(buf, iLineStart, i);
         else
@@ -2931,15 +2900,6 @@ private struct MarkdownList
         i = iStart - 1;
         iLineStart = i;
 
-        if (global.params.vmarkdown)
-        {
-            size_t iEnd = iStart;
-            while (iEnd < buf.length && buf[iEnd] != '\r' && buf[iEnd] != '\n')
-                ++iEnd;
-            const s = buf[][iStart..iEnd];
-            message(loc, "Ddoc: starting list item '%.*s'", cast(int)s.length, s.ptr);
-        }
-
         return true;
     }
 
@@ -3122,13 +3082,6 @@ private struct MarkdownLink
         immutable delta = replaceMarkdownEmphasis(buf, loc, inlineDelimiters, delimiterIndex);
         iEnd += delta;
         i += delta;
-
-        if (global.params.vmarkdown)
-        {
-            const s = buf[][delimiter.iStart..iEnd];
-            message(loc, "Ddoc: linking '%.*s' to '%.*s'", cast(int)s.length, s.ptr, cast(int)link.href.length, link.href.ptr);
-        }
-
         link.replaceLink(buf, i, iEnd, delimiter);
         return true;
     }
@@ -3532,9 +3485,6 @@ private struct MarkdownLink
      */
     private void storeAndReplaceDefinition(ref OutBuffer buf, ref size_t i, size_t iEnd, ref MarkdownLinkReferences linkReferences, const ref Loc loc)
     {
-        if (global.params.vmarkdown)
-            message(loc, "Ddoc: found link reference '%.*s' to '%.*s'", cast(int)label.length, label.ptr, cast(int)href.length, href.ptr);
-
         // Remove the definition and trailing whitespace
         iEnd = skipChars(buf, iEnd, " \t\r\n");
         buf.remove(i, iEnd - i);
@@ -4050,12 +4000,6 @@ private bool replaceTableRow(ref OutBuffer buf, size_t iStart, size_t iEnd, cons
     if (headerRow && cellCount != columnAlignments.length)
         return false;
 
-    if (headerRow && global.params.vmarkdown)
-    {
-        const s = buf[][iStart..iEnd];
-        message(loc, "Ddoc: formatting table '%.*s'", cast(int)s.length, s.ptr);
-    }
-
     void replaceTableCell(size_t iCellStart, size_t iCellEnd, int cellIndex, int di)
     {
         const eDelta = replaceMarkdownEmphasis(buf, loc, inlineDelimiters, di);
@@ -4378,17 +4322,8 @@ private void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, s
 
         case '>':
             {
-                if (leadingBlank && (!inCode || quoteLevel) && global.params.markdown)
+                if (leadingBlank && (!inCode || quoteLevel))
                 {
-                    if (!quoteLevel && global.params.vmarkdown)
-                    {
-                        size_t iEnd = i + 1;
-                        while (iEnd < buf.length && buf[iEnd] != '\n')
-                            ++iEnd;
-                        const s = buf[][i .. iEnd];
-                        message(loc, "Ddoc: starting quote block with '%.*s'", cast(int)s.length, s.ptr);
-                    }
-
                     lineQuoted = true;
                     int lineQuoteLevel = 1;
                     size_t iAfterDelimiters = i + 1;
@@ -4488,7 +4423,7 @@ private void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, s
                 }
 
                 // Perhaps we're starting or ending a Markdown code block
-                if (leadingBlank && global.params.markdown && count >= 3)
+                if (leadingBlank && count >= 3)
                 {
                     bool moreBackticks = false;
                     for (size_t j = iAfterDelimiter; !moreBackticks && j < buf.length; ++j)
@@ -4548,7 +4483,7 @@ private void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, s
 
         case '~':
             {
-                if (leadingBlank && global.params.markdown)
+                if (leadingBlank)
                 {
                     // Perhaps we're starting or ending a Markdown code block
                     const iAfterDelimiter = skipChars(buf, i, "~");
@@ -4613,7 +4548,7 @@ private void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, s
                     // BUG: handle UTF PS and LS too
                     if (c != c0 || iInfoString)
                     {
-                        if (global.params.markdown && !iInfoString && !inCode && i - istart >= 3)
+                        if (!iInfoString && !inCode && i - istart >= 3)
                         {
                             // Start a Markdown info string, like ```ruby
                             codeFenceLength = i - istart;
@@ -4711,9 +4646,6 @@ private void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, s
                             if (codeLanguage[j] == '\\' && ispunct(codeLanguage[j + 1]))
                                 codeLanguage = codeLanguage[0..j] ~ codeLanguage[j + 1..$];
 
-                        if (global.params.vmarkdown)
-                            message(loc, "Ddoc: adding code block for language '%.*s'", cast(int)codeLanguage.length, codeLanguage.ptr);
-
                         i = buf.insert(i, "$(OTHER_CODE ");
                         i = buf.insert(i, codeLanguage);
                         i = buf.insert(i, ",");
@@ -4779,7 +4711,7 @@ private void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, s
 
         case '*':
         {
-            if (inCode || inBacktick || !global.params.markdown)
+            if (inCode || inBacktick)
             {
                 leadingBlank = false;
                 break;
@@ -4829,7 +4761,7 @@ private void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, s
         {
             leadingBlank = false;
 
-            if (inCode || !global.params.markdown)
+            if (inCode)
                 break;
 
             if (i < buf.length-1 && buf[i+1] == '[')
@@ -4842,7 +4774,7 @@ private void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, s
         }
         case '[':
         {
-            if (inCode || !global.params.markdown)
+            if (inCode)
             {
                 leadingBlank = false;
                 break;
@@ -4860,7 +4792,7 @@ private void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, s
         {
             leadingBlank = false;
 
-            if (inCode || !global.params.markdown)
+            if (inCode)
                 break;
 
             for (int d = cast(int) inlineDelimiters.length - 1; d >= 0; --d)
@@ -4894,7 +4826,7 @@ private void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, s
 
         case '|':
         {
-            if (inCode || !global.params.markdown)
+            if (inCode)
             {
                 leadingBlank = false;
                 break;
@@ -4909,16 +4841,13 @@ private void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, s
         case '\\':
         {
             leadingBlank = false;
-            if (inCode || i+1 >= buf.length || !global.params.markdown)
+            if (inCode || i+1 >= buf.length)
                 break;
 
             /* Escape Markdown special characters */
             char c1 = buf[i+1];
             if (ispunct(c1))
             {
-                if (global.params.vmarkdown)
-                    message(loc, "Ddoc: backslash-escaped %c", c1);
-
                 buf.remove(i, 1);
 
                 auto se = sc._module.escapetable.escapeChar(c1);
index 6339a9e36baf218d70bb5ca8bf0626d5f95c68c7..b546e3720033d5e0fc2dc32bff8392044f9d53e6 100644 (file)
@@ -63,7 +63,6 @@ enum SCOPE
     free          = 0x8000,   /// is on free list
 
     fullinst      = 0x10000,  /// fully instantiate templates
-    alias_        = 0x20000,  /// inside alias declaration.
 
     // The following are mutually exclusive
     printf        = 0x4_0000, /// printf-style function
index 74eaa1d8d7ab78c84128c93eca94b22b9d69b8f8..b0069403408fa8cda0a4ccf5618e634be9f21474 100644 (file)
@@ -984,7 +984,7 @@ extern (C++) class Dsymbol : ASTNode
      */
     uinteger_t size(const ref Loc loc)
     {
-        error("Dsymbol `%s` has no size", toChars());
+        error("symbol `%s` has no size", toChars());
         return SIZE_INVALID;
     }
 
@@ -1641,6 +1641,32 @@ public:
         }
     }
 
+
+    /*****************************************
+     * Returns: the symbols whose members have been imported, i.e. imported modules
+     * and template mixins.
+     *
+     * See_Also: importScope
+     */
+    extern (D) final Dsymbols* getImportedScopes() nothrow @nogc @safe pure
+    {
+        return importedScopes;
+    }
+
+    /*****************************************
+     * Returns: the array of visibilities associated with each imported scope. The
+     * length of the array matches the imported scopes array.
+     *
+     * See_Also: getImportedScopes
+     */
+    extern (D) final Visibility.Kind[] getImportVisibilities() nothrow @nogc @safe pure
+    {
+        if (!importedScopes)
+            return null;
+
+        return (() @trusted => visibilities[0 .. importedScopes.dim])();
+    }
+
     extern (D) final void addAccessiblePackage(Package p, Visibility visibility) nothrow
     {
         auto pary = visibility.kind == Visibility.Kind.private_ ? &privateAccessiblePackages : &accessiblePackages;
index 5415401e0e4db22b072fd3bfe5a2f1b8546a7fa3..5d880560c4ee00e53a5ce7bbfeaf56848b7f5a8f 100644 (file)
@@ -376,7 +376,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         // https://issues.dlang.org/show_bug.cgi?id=19482
         if ((dsym.storage_class & (STC.foreach_ | STC.local)) == (STC.foreach_ | STC.local))
         {
-            dsym.linkage = LINK.d;
+            dsym._linkage = LINK.d;
             dsym.visibility = Visibility(Visibility.Kind.public_);
             dsym.overlapped = false; // unset because it is modified early on this function
             dsym.userAttribDecl = null; // unset because it is set by Dsymbol.setScope()
@@ -389,7 +389,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
             dsym.storage_class |= (sc.stc & ~(STC.synchronized_ | STC.override_ | STC.abstract_ | STC.final_));
             dsym.userAttribDecl = sc.userAttribDecl;
             dsym.cppnamespace = sc.namespace;
-            dsym.linkage = sc.linkage;
+            dsym._linkage = sc.linkage;
             dsym.visibility = sc.visibility;
             dsym.alignment = sc.alignment();
         }
@@ -472,8 +472,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         {
             if (dsym.storage_class & STC.gshared && !dsym.isMember())
             {
-                if (sc.func.setUnsafe())
-                    dsym.error("__gshared not allowed in safe functions; use shared");
+                sc.func.setUnsafe(false, dsym.loc, "__gshared not allowed in safe functions; use shared");
             }
         }
 
@@ -863,20 +862,18 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
             if (dsym._init && dsym._init.isVoidInitializer() &&
                 (dsym.type.hasPointers() || dsym.type.hasInvariant())) // also computes type size
             {
-                if (sc.func.setUnsafe())
-                {
-                    if (dsym.type.hasPointers())
-                        dsym.error("`void` initializers for pointers not allowed in safe functions");
-                    else
-                        dsym.error("`void` initializers for structs with invariants are not allowed in safe functions");
-                }
+                if (dsym.type.hasPointers())
+                    sc.func.setUnsafe(false, dsym.loc,
+                        "`void` initializers for pointers not allowed in safe functions");
+                else
+                    sc.func.setUnsafe(false, dsym.loc,
+                        "`void` initializers for structs with invariants are not allowed in safe functions");
             }
             else if (!dsym._init &&
                      !(dsym.storage_class & (STC.static_ | STC.extern_ | STC.gshared | STC.manifest | STC.field | STC.parameter)) &&
                      dsym.type.hasVoidInitPointers())
             {
-                if (sc.func.setUnsafe())
-                    dsym.error("`void` initializers for pointers not allowed in safe functions");
+                sc.func.setUnsafe(false, dsym.loc, "`void` initializers for pointers not allowed in safe functions");
             }
         }
 
@@ -891,6 +888,15 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         else if (dsym.storage_class & STC.manifest)
             dsym.error("manifest constants must have initializers");
 
+        // Don't allow non-extern, non-__gshared variables to be interfaced with C++
+        if (dsym._linkage == LINK.cpp && !(dsym.storage_class & (STC.ctfe | STC.extern_ | STC.gshared)) && dsym.isDataseg())
+        {
+            const char* p = (dsym.storage_class & STC.shared_) ? "shared" : "static";
+            dsym.error("cannot have `extern(C++)` linkage because it is `%s`", p);
+            errorSupplemental(dsym.loc, "perhaps declare it as `__gshared` instead");
+            dsym.errors = true;
+        }
+
         bool isBlit = false;
         uinteger_t sz;
         if (sc.flags & SCOPE.Cfile && !dsym._init)
@@ -1191,7 +1197,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
 
     override void visit(TypeInfoDeclaration dsym)
     {
-        assert(dsym.linkage == LINK.c);
+        assert(dsym._linkage == LINK.c);
     }
 
     override void visit(BitFieldDeclaration dsym)
@@ -1204,6 +1210,11 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         if (dsym.errors)
             return;
 
+        if (!dsym.parent.isStructDeclaration() && !dsym.parent.isClassDeclaration())
+        {
+            dsym.error("bit-field must be member of struct, union, or class");
+        }
+
         sc = sc.startCTFE();
         auto width = dsym.width.expressionSemantic(sc);
         sc = sc.endCTFE();
@@ -1239,7 +1250,12 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
 
     override void visit(Import imp)
     {
-        //printf("Import::semantic('%s') %s\n", toPrettyChars(), id.toChars());
+        static if (LOG)
+        {
+            printf("Import::semantic('%s') %s\n", toPrettyChars(), id.toChars());
+            scope(exit)
+                printf("-Import::semantic('%s'), pkg = %p\n", toChars(), pkg);
+        }
         if (imp.semanticRun > PASS.initial)
             return;
 
@@ -1349,70 +1365,69 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         // don't list pseudo modules __entrypoint.d, __main.d
         // https://issues.dlang.org/show_bug.cgi?id=11117
         // https://issues.dlang.org/show_bug.cgi?id=11164
-        if (global.params.moduleDeps !is null && !(imp.id == Id.object && sc._module.ident == Id.object) &&
-            strcmp(sc._module.ident.toChars(), "__main") != 0)
-        {
-            /* The grammar of the file is:
-             *      ImportDeclaration
-             *          ::= BasicImportDeclaration [ " : " ImportBindList ] [ " -> "
-             *      ModuleAliasIdentifier ] "\n"
-             *
-             *      BasicImportDeclaration
-             *          ::= ModuleFullyQualifiedName " (" FilePath ") : " Protection|"string"
-             *              " [ " static" ] : " ModuleFullyQualifiedName " (" FilePath ")"
-             *
-             *      FilePath
-             *          - any string with '(', ')' and '\' escaped with the '\' character
-             */
-            OutBuffer* ob = global.params.moduleDeps;
-            Module imod = sc._module;
-            if (!global.params.moduleDepsFile)
-                ob.writestring("depsImport ");
-            ob.writestring(imod.toPrettyChars());
-            ob.writestring(" (");
-            escapePath(ob, imod.srcfile.toChars());
-            ob.writestring(") : ");
-            // use visibility instead of sc.visibility because it couldn't be
-            // resolved yet, see the comment above
-            visibilityToBuffer(ob, imp.visibility);
+        if (global.params.moduleDeps.buffer is null || (imp.id == Id.object && sc._module.ident == Id.object) ||
+            strcmp(sc._module.ident.toChars(), "__main") == 0)
+            return;
+
+        /* The grammar of the file is:
+         *      ImportDeclaration
+         *          ::= BasicImportDeclaration [ " : " ImportBindList ] [ " -> "
+         *      ModuleAliasIdentifier ] "\n"
+         *
+         *      BasicImportDeclaration
+         *          ::= ModuleFullyQualifiedName " (" FilePath ") : " Protection|"string"
+         *              " [ " static" ] : " ModuleFullyQualifiedName " (" FilePath ")"
+         *
+         *      FilePath
+         *          - any string with '(', ')' and '\' escaped with the '\' character
+         */
+        OutBuffer* ob = global.params.moduleDeps.buffer;
+        Module imod = sc._module;
+        if (!global.params.moduleDeps.name)
+            ob.writestring("depsImport ");
+        ob.writestring(imod.toPrettyChars());
+        ob.writestring(" (");
+        escapePath(ob, imod.srcfile.toChars());
+        ob.writestring(") : ");
+        // use visibility instead of sc.visibility because it couldn't be
+        // resolved yet, see the comment above
+        visibilityToBuffer(ob, imp.visibility);
+        ob.writeByte(' ');
+        if (imp.isstatic)
+        {
+            stcToBuffer(ob, STC.static_);
             ob.writeByte(' ');
-            if (imp.isstatic)
-            {
-                stcToBuffer(ob, STC.static_);
-                ob.writeByte(' ');
-            }
-            ob.writestring(": ");
-            foreach (pid; imp.packages)
-            {
-                ob.printf("%s.", pid.toChars());
-            }
-            ob.writestring(imp.id.toString());
-            ob.writestring(" (");
-            if (imp.mod)
-                escapePath(ob, imp.mod.srcfile.toChars());
+        }
+        ob.writestring(": ");
+        foreach (pid; imp.packages)
+        {
+            ob.printf("%s.", pid.toChars());
+        }
+        ob.writestring(imp.id.toString());
+        ob.writestring(" (");
+        if (imp.mod)
+            escapePath(ob, imp.mod.srcfile.toChars());
+        else
+            ob.writestring("???");
+        ob.writeByte(')');
+        foreach (i, name; imp.names)
+        {
+            if (i == 0)
+                ob.writeByte(':');
             else
-                ob.writestring("???");
-            ob.writeByte(')');
-            foreach (i, name; imp.names)
+                ob.writeByte(',');
+            Identifier _alias = imp.aliases[i];
+            if (!_alias)
             {
-                if (i == 0)
-                    ob.writeByte(':');
-                else
-                    ob.writeByte(',');
-                Identifier _alias = imp.aliases[i];
-                if (!_alias)
-                {
-                    ob.printf("%s", name.toChars());
-                    _alias = name;
-                }
-                else
-                    ob.printf("%s=%s", _alias.toChars(), name.toChars());
+                ob.printf("%s", name.toChars());
+                _alias = name;
             }
-            if (imp.aliasId)
-                ob.printf(" -> %s", imp.aliasId.toChars());
-            ob.writenl();
+            else
+                ob.printf("%s=%s", _alias.toChars(), name.toChars());
         }
-        //printf("-Import::semantic('%s'), pkg = %p\n", toChars(), pkg);
+        if (imp.aliasId)
+            ob.printf(" -> %s", imp.aliasId.toChars());
+        ob.writenl();
     }
 
     void attribSemantic(AttribDeclaration ad)
@@ -1457,24 +1472,24 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
             return;
         }
 
-        if (scd.decl)
+        if (!scd.decl)
+            return;
+
+        sc = sc.push();
+        sc.stc &= ~(STC.auto_ | STC.scope_ | STC.static_ | STC.gshared);
+        sc.inunion = scd.isunion ? scd : null;
+        sc.flags = 0;
+        for (size_t i = 0; i < scd.decl.dim; i++)
         {
-            sc = sc.push();
-            sc.stc &= ~(STC.auto_ | STC.scope_ | STC.static_ | STC.gshared);
-            sc.inunion = scd.isunion ? scd : null;
-            sc.flags = 0;
-            for (size_t i = 0; i < scd.decl.dim; i++)
+            Dsymbol s = (*scd.decl)[i];
+            if (auto var = s.isVarDeclaration)
             {
-                Dsymbol s = (*scd.decl)[i];
-                if (auto var = s.isVarDeclaration)
-                {
-                    if (scd.isunion)
-                        var.overlapped = true;
-                }
-                s.dsymbolSemantic(sc);
+                if (scd.isunion)
+                    var.overlapped = true;
             }
-            sc = sc.pop();
+            s.dsymbolSemantic(sc);
         }
+        sc = sc.pop();
     }
 
     override void visit(PragmaDeclaration pd)
@@ -1633,32 +1648,33 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         }
         if (pd.ident == Id.msg)
         {
-            if (pd.args)
+            if (!pd.args)
+                return noDeclarations();
+
+            for (size_t i = 0; i < pd.args.dim; i++)
             {
-                for (size_t i = 0; i < pd.args.dim; i++)
+                Expression e = (*pd.args)[i];
+                sc = sc.startCTFE();
+                e = e.expressionSemantic(sc);
+                e = resolveProperties(sc, e);
+                sc = sc.endCTFE();
+                e = ctfeInterpretForPragmaMsg(e);
+                if (e.op == EXP.error)
                 {
-                    Expression e = (*pd.args)[i];
-                    sc = sc.startCTFE();
-                    e = e.expressionSemantic(sc);
-                    e = resolveProperties(sc, e);
-                    sc = sc.endCTFE();
-                    e = ctfeInterpretForPragmaMsg(e);
-                    if (e.op == EXP.error)
-                    {
-                        errorSupplemental(pd.loc, "while evaluating `pragma(msg, %s)`", (*pd.args)[i].toChars());
-                        return;
-                    }
-                    StringExp se = e.toStringExp();
-                    if (se)
-                    {
-                        se = se.toUTF8(sc);
-                        fprintf(stderr, "%.*s", cast(int)se.len, se.peekString().ptr);
-                    }
-                    else
-                        fprintf(stderr, "%s", e.toChars());
+                    errorSupplemental(pd.loc, "while evaluating `pragma(msg, %s)`", (*pd.args)[i].toChars());
+                    return;
                 }
-                fprintf(stderr, "\n");
+                StringExp se = e.toStringExp();
+                if (se)
+                {
+                    se = se.toUTF8(sc);
+                    fprintf(stderr, "%.*s", cast(int)se.len, se.peekString().ptr);
+                }
+                else
+                    fprintf(stderr, "%s", e.toChars());
             }
+            fprintf(stderr, "\n");
+
             return noDeclarations();
         }
         else if (pd.ident == Id.lib)
@@ -1675,9 +1691,9 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
                 auto name = se.peekString().xarraydup;
                 if (global.params.verbose)
                     message("library   %s", name.ptr);
-                if (global.params.moduleDeps && !global.params.moduleDepsFile)
+                if (global.params.moduleDeps.buffer && !global.params.moduleDeps.name)
                 {
-                    OutBuffer* ob = global.params.moduleDeps;
+                    OutBuffer* ob = global.params.moduleDeps.buffer;
                     Module imod = sc._module;
                     ob.writestring("depsLib ");
                     ob.writestring(imod.toPrettyChars());
@@ -1892,49 +1908,49 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
                 return Identifier.idPool(sident);
         }
 
-        if (ns.ident is null)
-        {
-            ns.cppnamespace = sc.namespace;
-            sc = sc.startCTFE();
-            ns.exp = ns.exp.expressionSemantic(sc);
-            ns.exp = resolveProperties(sc, ns.exp);
-            sc = sc.endCTFE();
-            ns.exp = ns.exp.ctfeInterpret();
-            // Can be either a tuple of strings or a string itself
-            if (auto te = ns.exp.isTupleExp())
-            {
-                expandTuples(te.exps);
-                CPPNamespaceDeclaration current = ns.cppnamespace;
-                for (size_t d = 0; d < te.exps.dim; ++d)
+        if (ns.ident !is null)
+            return attribSemantic(ns);
+
+        ns.cppnamespace = sc.namespace;
+        sc = sc.startCTFE();
+        ns.exp = ns.exp.expressionSemantic(sc);
+        ns.exp = resolveProperties(sc, ns.exp);
+        sc = sc.endCTFE();
+        ns.exp = ns.exp.ctfeInterpret();
+        // Can be either a tuple of strings or a string itself
+        if (auto te = ns.exp.isTupleExp())
+        {
+            expandTuples(te.exps);
+            CPPNamespaceDeclaration current = ns.cppnamespace;
+            for (size_t d = 0; d < te.exps.dim; ++d)
+            {
+                auto exp = (*te.exps)[d];
+                auto prev = d ? current : ns.cppnamespace;
+                current = (d + 1) != te.exps.dim
+                    ? new CPPNamespaceDeclaration(ns.loc, exp, null)
+                    : ns;
+                current.exp = exp;
+                current.cppnamespace = prev;
+                if (auto se = exp.toStringExp())
                 {
-                    auto exp = (*te.exps)[d];
-                    auto prev = d ? current : ns.cppnamespace;
-                    current = (d + 1) != te.exps.dim
-                        ? new CPPNamespaceDeclaration(ns.loc, exp, null)
-                        : ns;
-                    current.exp = exp;
-                    current.cppnamespace = prev;
-                    if (auto se = exp.toStringExp())
-                    {
-                        current.ident = identFromSE(se);
-                        if (current.ident is null)
-                            return; // An error happened in `identFromSE`
-                    }
-                    else
-                        ns.exp.error("`%s`: index %llu is not a string constant, it is a `%s`",
-                                     ns.exp.toChars(), cast(ulong) d, ns.exp.type.toChars());
+                    current.ident = identFromSE(se);
+                    if (current.ident is null)
+                        return; // An error happened in `identFromSE`
                 }
+                else
+                    ns.exp.error("`%s`: index %llu is not a string constant, it is a `%s`",
+                                 ns.exp.toChars(), cast(ulong) d, ns.exp.type.toChars());
             }
-            else if (auto se = ns.exp.toStringExp())
-                ns.ident = identFromSE(se);
-            // Empty Tuple
-            else if (ns.exp.isTypeExp() && ns.exp.isTypeExp().type.toBasetype().isTypeTuple())
-            {
-            }
-            else
-                ns.exp.error("compile time string constant (or tuple) expected, not `%s`",
-                             ns.exp.toChars());
         }
+        else if (auto se = ns.exp.toStringExp())
+            ns.ident = identFromSE(se);
+        // Empty Tuple
+        else if (ns.exp.isTypeExp() && ns.exp.isTypeExp().type.toBasetype().isTypeTuple())
+        {
+        }
+        else
+            ns.exp.error("compile time string constant (or tuple) expected, not `%s`",
+                         ns.exp.toChars());
         attribSemantic(ns);
     }
 
@@ -2174,7 +2190,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
 
                 em.semanticRun = PASS.semantic;
                 em.type = Type.tint32;
-                em.linkage = LINK.c;
+                em._linkage = LINK.c;
                 em.storage_class |= STC.manifest;
                 if (em.value)
                 {
@@ -2264,7 +2280,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         em.semanticRun = PASS.semantic;
 
         em.visibility = em.ed.isAnonymous() ? em.ed.visibility : Visibility(Visibility.Kind.public_);
-        em.linkage = LINK.d;
+        em._linkage = LINK.d;
         em.storage_class |= STC.manifest;
 
         // https://issues.dlang.org/show_bug.cgi?id=9701
@@ -2538,7 +2554,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         Scope* paramscope = sc.push(paramsym);
         paramscope.stc = 0;
 
-        if (global.params.doDocComments)
+        if (global.params.ddoc.doOutput)
         {
             tempdecl.origParameters = new TemplateParameters(tempdecl.parameters.dim);
             for (size_t i = 0; i < tempdecl.parameters.dim; i++)
@@ -2824,7 +2840,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
          */
         //if (!sc.func && Module.deferred.dim > deferred_dim) {}
 
-        AggregateDeclaration ad = tm.toParent().isAggregateDeclaration();
+        AggregateDeclaration ad = tm.isMember();
         if (sc.func && !ad)
         {
             tm.semantic2(sc2);
@@ -2855,6 +2871,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         static if (LOG)
         {
             printf("+Nspace::semantic('%s')\n", ns.toChars());
+            scope(exit) printf("-Nspace::semantic('%s')\n", ns.toChars());
         }
         if (ns._scope)
         {
@@ -2931,36 +2948,34 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         // Link does not matter here, if the UDA is present it will error
         UserAttributeDeclaration.checkGNUABITag(ns, LINK.cpp);
 
-        if (ns.members)
+        if (!ns.members)
+        {
+            ns.semanticRun = PASS.semanticdone;
+            return;
+        }
+        assert(sc);
+        sc = sc.push(ns);
+        sc.linkage = LINK.cpp; // note that namespaces imply C++ linkage
+        sc.parent = ns;
+        foreach (s; *ns.members)
         {
-            assert(sc);
-            sc = sc.push(ns);
-            sc.linkage = LINK.cpp; // note that namespaces imply C++ linkage
-            sc.parent = ns;
-            foreach (s; *ns.members)
+            if (repopulateMembers)
             {
-                if (repopulateMembers)
-                {
-                    s.addMember(sc, sc.scopesym);
-                    s.setScope(sc);
-                }
-                s.importAll(sc);
+                s.addMember(sc, sc.scopesym);
+                s.setScope(sc);
             }
-            foreach (s; *ns.members)
+            s.importAll(sc);
+        }
+        foreach (s; *ns.members)
+        {
+            static if (LOG)
             {
-                static if (LOG)
-                {
-                    printf("\tmember '%s', kind = '%s'\n", s.toChars(), s.kind());
-                }
-                s.dsymbolSemantic(sc);
+                printf("\tmember '%s', kind = '%s'\n", s.toChars(), s.kind());
             }
-            sc.pop();
+            s.dsymbolSemantic(sc);
         }
+        sc.pop();
         ns.semanticRun = PASS.semanticdone;
-        static if (LOG)
-        {
-            printf("-Nspace::semantic('%s')\n", ns.toChars());
-        }
     }
 
     void funcDeclarationSemantic(FuncDeclaration funcdecl)
@@ -3024,7 +3039,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         if (sc.flags & SCOPE.compile)
             funcdecl.flags |= FUNCFLAG.compileTimeOnly; // don't emit code for this function
 
-        funcdecl.linkage = sc.linkage;
+        funcdecl._linkage = sc.linkage;
         if (auto fld = funcdecl.isFuncLiteralDeclaration())
         {
             if (fld.treq)
@@ -3037,7 +3052,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
                     fld.tok = TOK.function_;
                 else
                     assert(0);
-                funcdecl.linkage = treq.nextOf().toTypeFunction().linkage;
+                funcdecl._linkage = treq.nextOf().toTypeFunction().linkage;
             }
         }
 
@@ -3045,19 +3060,9 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
         if (auto pragmadecl = sc.inlining)
             funcdecl.inlining = pragmadecl.evalPragmaInline(sc);
 
-        // check pragma(crt_constructor)
-        if (funcdecl.flags & (FUNCFLAG.CRTCtor | FUNCFLAG.CRTDtor))
-        {
-            if (funcdecl.linkage != LINK.c)
-            {
-                funcdecl.error("must be `extern(C)` for `pragma(%s)`",
-                    (funcdecl.flags & FUNCFLAG.CRTCtor) ? "crt_constructor".ptr : "crt_destructor".ptr);
-            }
-        }
-
         funcdecl.visibility = sc.visibility;
         funcdecl.userAttribDecl = sc.userAttribDecl;
-        UserAttributeDeclaration.checkGNUABITag(funcdecl, funcdecl.linkage);
+        UserAttributeDeclaration.checkGNUABITag(funcdecl, funcdecl._linkage);
         checkMustUseReserved(funcdecl);
 
         if (!funcdecl.originalType)
@@ -3193,7 +3198,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
                 tf.isScopeQual = false;
             }
 
-            sc.linkage = funcdecl.linkage;
+            sc.linkage = funcdecl._linkage;
 
             if (!tf.isNaked() && !(funcdecl.isThis() || funcdecl.isNested()))
             {
@@ -3243,6 +3248,16 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
             funcdecl.storage_class &= ~(STC.TYPECTOR | STC.FUNCATTR);
         }
 
+        // check pragma(crt_constructor) signature
+        if (funcdecl.flags & (FUNCFLAG.CRTCtor | FUNCFLAG.CRTDtor))
+        {
+            const idStr = (funcdecl.flags & FUNCFLAG.CRTCtor) ? "crt_constructor" : "crt_destructor";
+            if (f.nextOf().ty != Tvoid)
+                funcdecl.error("must return `void` for `pragma(%s)`", idStr.ptr);
+            if (funcdecl._linkage != LINK.c && f.parameterList.length != 0)
+                funcdecl.error("must be `extern(C)` for `pragma(%s)` when taking parameters", idStr.ptr);
+        }
+
         if (funcdecl.overnext && funcdecl.isCsymbol())
         {
             /* C does not allow function overloading, but it does allow
@@ -4027,67 +4042,67 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
          */
         if (ad && (!ctd.parent.isTemplateInstance() || ctd.parent.isTemplateMixin()))
         {
-            if (sd)
+            if (!sd)
             {
-                if (dim == 0 && tf.parameterList.varargs == VarArg.none) // empty default ctor w/o any varargs
-                {
-                    if (ctd.fbody || !(ctd.storage_class & STC.disable))
-                    {
-                        ctd.error("default constructor for structs only allowed " ~
-                            "with `@disable`, no body, and no parameters");
-                        ctd.storage_class |= STC.disable;
-                        ctd.fbody = null;
-                    }
-                    sd.noDefaultCtor = true;
-                }
-                else if (dim == 0 && tf.parameterList.varargs != VarArg.none) // allow varargs only ctor
-                {
-                }
-                else if (dim && tf.parameterList[0].defaultArg)
+                if (dim == 0 && tf.parameterList.varargs == VarArg.none)
+                    ad.defaultCtor = ctd;
+                return;
+            }
+
+            if (dim == 0 && tf.parameterList.varargs == VarArg.none) // empty default ctor w/o any varargs
+            {
+                if (ctd.fbody || !(ctd.storage_class & STC.disable))
                 {
-                    // if the first parameter has a default argument, then the rest does as well
-                    if (ctd.storage_class & STC.disable)
-                    {
-                        ctd.error("is marked `@disable`, so it cannot have default "~
-                                  "arguments for all parameters.");
-                        errorSupplemental(ctd.loc, "Use `@disable this();` if you want to disable default initialization.");
-                    }
-                    else
-                        ctd.error("all parameters have default arguments, "~
-                                  "but structs cannot have default constructors.");
+                    ctd.error("default constructor for structs only allowed " ~
+                        "with `@disable`, no body, and no parameters");
+                    ctd.storage_class |= STC.disable;
+                    ctd.fbody = null;
                 }
-                else if ((dim == 1 || (dim > 1 && tf.parameterList[1].defaultArg)))
+                sd.noDefaultCtor = true;
+            }
+            else if (dim == 0 && tf.parameterList.varargs != VarArg.none) // allow varargs only ctor
+            {
+            }
+            else if (dim && tf.parameterList[0].defaultArg)
+            {
+                // if the first parameter has a default argument, then the rest does as well
+                if (ctd.storage_class & STC.disable)
                 {
-                    //printf("tf: %s\n", tf.toChars());
-                    auto param = tf.parameterList[0];
-                    if (param.storageClass & STC.ref_ && param.type.mutableOf().unSharedOf() == sd.type.mutableOf().unSharedOf())
-                    {
-                        //printf("copy constructor\n");
-                        ctd.isCpCtor = true;
-                    }
+                    ctd.error("is marked `@disable`, so it cannot have default "~
+                              "arguments for all parameters.");
+                    errorSupplemental(ctd.loc, "Use `@disable this();` if you want to disable default initialization.");
                 }
+                else
+                    ctd.error("all parameters have default arguments, "~
+                              "but structs cannot have default constructors.");
             }
-            else if (dim == 0 && tf.parameterList.varargs == VarArg.none)
+            else if ((dim == 1 || (dim > 1 && tf.parameterList[1].defaultArg)))
             {
-                ad.defaultCtor = ctd;
+                //printf("tf: %s\n", tf.toChars());
+                auto param = tf.parameterList[0];
+                if (param.storageClass & STC.ref_ && param.type.mutableOf().unSharedOf() == sd.type.mutableOf().unSharedOf())
+                {
+                    //printf("copy constructor\n");
+                    ctd.isCpCtor = true;
+                }
             }
         }
         // https://issues.dlang.org/show_bug.cgi?id=22593
         else if (auto ti = ctd.parent.isTemplateInstance())
         {
-            if (sd && sd.hasCopyCtor && (dim == 1 || (dim > 1 && tf.parameterList[1].defaultArg)))
-            {
-                auto param = tf.parameterList[0];
+            if (!sd || !sd.hasCopyCtor || !(dim == 1 || (dim > 1 && tf.parameterList[1].defaultArg)))
+                return;
 
-                // if the template instance introduces an rvalue constructor
-                // between the members of a struct declaration, we should check if a
-                // copy constructor exists and issue an error in that case.
-                if (!(param.storageClass & STC.ref_) && param.type.mutableOf().unSharedOf() == sd.type.mutableOf().unSharedOf())
-                {
-                    .error(ctd.loc, "Cannot define both an rvalue constructor and a copy constructor for `struct %s`", sd.toChars);
-                    .errorSupplemental(ti.loc, "Template instance `%s` creates a rvalue constructor for `struct %s`",
-                            ti.toChars(), sd.toChars());
-                }
+            auto param = tf.parameterList[0];
+
+            // if the template instance introduces an rvalue constructor
+            // between the members of a struct declaration, we should check if a
+            // copy constructor exists and issue an error in that case.
+            if (!(param.storageClass & STC.ref_) && param.type.mutableOf().unSharedOf() == sd.type.mutableOf().unSharedOf())
+            {
+                .error(ctd.loc, "cannot define both an rvalue constructor and a copy constructor for `struct %s`", sd.toChars);
+                .errorSupplemental(ti.loc, "Template instance `%s` creates a rvalue constructor for `struct %s`",
+                        ti.toChars(), sd.toChars());
             }
         }
     }
@@ -6417,13 +6432,8 @@ void aliasSemantic(AliasDeclaration ds, Scope* sc)
     ds.visibility = sc.visibility;
     ds.userAttribDecl = sc.userAttribDecl;
 
-    // TypeTraits needs to know if it's located in an AliasDeclaration
-    const oldflags = sc.flags;
-    sc.flags |= SCOPE.alias_;
-
     void normalRet()
     {
-        sc.flags = oldflags;
         ds.inuse = 0;
         ds.semanticRun = PASS.semanticdone;
 
index fb41e2bd05f5c4e224d6f4c118862d18ab5e579a..ed0126eeef6fb2f86de7be7bc69664707ce5d475 100644 (file)
@@ -2777,7 +2777,7 @@ void functionResolve(ref MatchAccumulator m, Dsymbol dstart, Loc loc, Scope* sc,
             fd.storage_class == m.lastf.storage_class &&
             fd.parent == m.lastf.parent &&
             fd.visibility == m.lastf.visibility &&
-            fd.linkage == m.lastf.linkage)
+            fd._linkage == m.lastf._linkage)
         {
             if (fd.fbody && !m.lastf.fbody)
                 goto LfIsBetter;
index 41fb82b8266f7fd13851667f296aed7b33abef86..55f7c724e5ac895de42a48f56627ccde3886c103 100644 (file)
@@ -82,7 +82,7 @@ extern(C++) void genCppHdrFiles(ref Modules ms)
     foreach (m; ms)
         m.accept(v);
 
-    if (global.params.doCxxHdrGeneration == CxxHeaderMode.verbose)
+    if (global.params.cxxhdr.fullOutput)
         buf.printf("// Automatically generated by %s Compiler v%d", global.vendor.ptr, global.versionNumber());
     else
         buf.printf("// Automatically generated by %s Compiler", global.vendor.ptr);
@@ -92,9 +92,9 @@ extern(C++) void genCppHdrFiles(ref Modules ms)
     buf.writestringln("#pragma once");
     buf.writenl();
     hashInclude(buf, "<assert.h>");
+    hashInclude(buf, "<math.h>");
     hashInclude(buf, "<stddef.h>");
     hashInclude(buf, "<stdint.h>");
-    hashInclude(buf, "<math.h>");
 //    buf.writestring(buf, "#include <stdio.h>\n");
 //    buf.writestring("#include <string.h>\n");
 
@@ -189,7 +189,7 @@ struct _d_dynamicArray final
             buf.remove(buf.length - 1, 1);
 
 
-    if (global.params.cxxhdrname is null)
+    if (global.params.cxxhdr.name is null)
     {
         // Write to stdout; assume it succeeds
         size_t n = fwrite(buf[].ptr, 1, buf.length, stdout);
@@ -197,7 +197,7 @@ struct _d_dynamicArray final
     }
     else
     {
-        const(char)[] name = FileName.combine(global.params.cxxhdrdir, global.params.cxxhdrname);
+        const(char)[] name = FileName.combine(global.params.cxxhdr.dir, global.params.cxxhdr.name);
         writeFile(Loc.initial, name, buf[]);
     }
 }
@@ -297,7 +297,7 @@ public:
         this.fwdbuf = fwdbuf;
         this.donebuf = donebuf;
         this.buf = buf;
-        this.printIgnored = global.params.doCxxHdrGeneration == CxxHeaderMode.verbose;
+        this.printIgnored = global.params.cxxhdr.fullOutput;
     }
 
     /**
@@ -966,12 +966,13 @@ public:
         if (vd.storage_class & (AST.STC.static_ | AST.STC.extern_ | AST.STC.gshared) ||
         vd.parent && vd.parent.isModule())
         {
-            if (vd.linkage != LINK.c && vd.linkage != LINK.cpp && !(tdparent && (this.linkage == LINK.c || this.linkage == LINK.cpp)))
+            const vdLinkage = vd.resolvedLinkage();
+            if (vdLinkage != LINK.c && vdLinkage != LINK.cpp && !(tdparent && (this.linkage == LINK.c || this.linkage == LINK.cpp)))
             {
                 ignored("variable %s because of linkage", vd.toPrettyChars());
                 return;
             }
-            if (vd.mangleOverride && vd.linkage != LINK.c)
+            if (vd.mangleOverride && vdLinkage != LINK.c)
             {
                 ignored("variable %s because C++ doesn't support explicit mangling", vd.toPrettyChars());
                 return;
@@ -987,7 +988,7 @@ public:
                 return;
             }
             writeProtection(vd.visibility.kind);
-            if (vd.linkage == LINK.c)
+            if (vdLinkage == LINK.c)
                 buf.writestring("extern \"C\" ");
             else if (!adparent)
                 buf.writestring("extern ");
@@ -2302,7 +2303,7 @@ public:
             this.forwarding = fwdStash;
         }
 
-        if (p.storageClass & AST.STC.ref_)
+        if (p.storageClass & (AST.STC.ref_ | AST.STC.out_))
             buf.writeByte('&');
         buf.writeByte(' ');
         if (ident)
@@ -2805,7 +2806,10 @@ public:
 
         // Check against the internal information which might be missing, e.g. inside of template declarations
         if (auto dec = sym.isDeclaration())
-            return dec.linkage == LINK.cpp || dec.linkage == LINK.c;
+        {
+            const l = dec.resolvedLinkage();
+            return l == LINK.cpp || l == LINK.c;
+        }
 
         if (auto ad = sym.isAggregateDeclaration())
             return ad.classKind == ClassKind.cpp;
@@ -2853,8 +2857,11 @@ public:
         if (!res)
         {
             // Check against the internal information which might be missing, e.g. inside of template declarations
-            auto dec = sym.isDeclaration();
-            res = dec && (dec.linkage == LINK.cpp || dec.linkage == LINK.c);
+            if (auto dec = sym.isDeclaration())
+            {
+                const l = dec.resolvedLinkage();
+                res = (l == LINK.cpp || l == LINK.c);
+            }
         }
 
         // Remember result for later calls
index 44c3757248bedf97cf696b135e573d91a44b6c93..3f41c298c2c9c5b9592f6c24b61add318b81cad7 100644 (file)
@@ -280,13 +280,14 @@ bool checkAssocArrayLiteralEscape(Scope *sc, AssocArrayLiteralExp ae, bool gag)
  *      sc = used to determine current function and module
  *      fdc = function being called, `null` if called indirectly
  *      par = function parameter (`this` if null)
+ *      parStc = storage classes of function parameter (may have added `scope` from `pure`)
  *      arg = initializer for param
  *      assertmsg = true if the parameter is the msg argument to assert(bool, msg).
  *      gag = do not print error messages
  * Returns:
  *      `true` if pointers to the stack can escape via assignment
  */
-bool checkParamArgumentEscape(Scope* sc, FuncDeclaration fdc, Parameter par, Expression arg, bool assertmsg, bool gag)
+bool checkParamArgumentEscape(Scope* sc, FuncDeclaration fdc, Parameter par, STC parStc, Expression arg, bool assertmsg, bool gag)
 {
     enum log = false;
     if (log) printf("checkParamArgumentEscape(arg: %s par: %s)\n",
@@ -301,42 +302,38 @@ bool checkParamArgumentEscape(Scope* sc, FuncDeclaration fdc, Parameter par, Exp
 
     escapeByValue(arg, &er);
 
+    if (parStc & STC.scope_)
+    {
+        // These errors only apply to non-scope parameters
+        // When the paraneter is `scope`, only `checkScopeVarAddr` on `er.byref` is needed
+        er.byfunc.setDim(0);
+        er.byvalue.setDim(0);
+        er.byexp.setDim(0);
+    }
+
     if (!er.byref.dim && !er.byvalue.dim && !er.byfunc.dim && !er.byexp.dim)
         return false;
 
     bool result = false;
 
-    ScopeRef psr;
-    if (par && fdc && fdc.type.isTypeFunction())
-        psr = buildScopeRef(par.storageClass);
-    else
-        psr = ScopeRef.None;
-
     /* 'v' is assigned unsafely to 'par'
      */
-    void unsafeAssign(VarDeclaration v, const char* desc)
+    void unsafeAssign(string desc)(VarDeclaration v)
     {
-        if (setUnsafeDIP1000(sc.func))
+        if (assertmsg)
         {
-            if (!gag)
-            {
-                if (assertmsg)
-                {
-                    previewErrorFunc(sc.isDeprecated(), global.params.useDIP1000)
-                                    (arg.loc, "%s `%s` assigned to non-scope parameter calling `assert()`",
-                        desc, v.toChars());
-                }
-                else
-                {
-                    previewErrorFunc(sc.isDeprecated(), global.params.useDIP1000)
-                                    (arg.loc, "%s `%s` assigned to non-scope parameter `%s` calling %s",
-                        desc, v.toChars(),
-                        par ? par.toChars() : "this",
-                        fdc ? fdc.toPrettyChars() : "indirectly");
-                }
-            }
-            if (global.params.useDIP1000 == FeatureState.enabled)
-                result = true;
+            result |= sc.setUnsafeDIP1000(gag, arg.loc,
+                desc ~ " `%s` assigned to non-scope parameter calling `assert()`", v);
+        }
+        else if (par)
+        {
+            result |= sc.setUnsafeDIP1000(gag, arg.loc,
+                desc ~ " `%s` assigned to non-scope parameter `%s`", v, par);
+        }
+        else
+        {
+            result |= sc.setUnsafeDIP1000(gag, arg.loc,
+                desc ~ " `%s` assigned to non-scope parameter `this`", v);
         }
     }
 
@@ -352,14 +349,14 @@ bool checkParamArgumentEscape(Scope* sc, FuncDeclaration fdc, Parameter par, Exp
 
         if (v.isScope())
         {
-            unsafeAssign(v, "scope variable");
+            unsafeAssign!"scope variable"(v);
         }
         else if (v.storage_class & STC.variadic && p == sc.func)
         {
             Type tb = v.type.toBasetype();
             if (tb.ty == Tarray || tb.ty == Tsarray)
             {
-                unsafeAssign(v, "variadic variable");
+                unsafeAssign!"variadic variable"(v);
             }
         }
         else
@@ -382,17 +379,15 @@ bool checkParamArgumentEscape(Scope* sc, FuncDeclaration fdc, Parameter par, Exp
         Dsymbol p = v.toParent2();
 
         notMaybeScope(v);
-
-        if (p == sc.func)
+        if (checkScopeVarAddr(v, arg, sc, gag))
         {
-            if (psr == ScopeRef.Scope ||
-                psr == ScopeRef.RefScope ||
-                psr == ScopeRef.ReturnRef_Scope)
-            {
-                continue;
-            }
+            result = true;
+            continue;
+        }
 
-            unsafeAssign(v, "reference to local variable");
+        if (p == sc.func && !(parStc & STC.scope_))
+        {
+            unsafeAssign!"reference to local variable"(v);
             continue;
         }
     }
@@ -414,21 +409,26 @@ bool checkParamArgumentEscape(Scope* sc, FuncDeclaration fdc, Parameter par, Exp
 
             if ((v.isReference() || v.isScope()) && p == sc.func)
             {
-                unsafeAssign(v, "reference to local");
+                unsafeAssign!"reference to local"(v);
                 continue;
             }
         }
     }
 
+    if (!sc.func)
+        return result;
+
     foreach (Expression ee; er.byexp)
     {
-        if (sc.func && sc.func.setUnsafe())
+        if (!par)
         {
-            if (!gag)
-                error(ee.loc, "reference to stack allocated value returned by `%s` assigned to non-scope parameter `%s`",
-                    ee.toChars(),
-                    par ? par.toChars() : "this");
-            result = true;
+            result |= sc.setUnsafeDIP1000(gag, ee.loc,
+                "reference to stack allocated value returned by `%s` assigned to non-scope parameter `this`", ee);
+        }
+        else
+        {
+            result |= sc.setUnsafeDIP1000(gag, ee.loc,
+                "reference to stack allocated value returned by `%s` assigned to non-scope parameter `%s`", ee, par);
         }
     }
 
@@ -688,25 +688,25 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag, bool byRef)
                 }
             }
 
-            if (va && va.isScope() && va.storage_class & STC.return_ && !(v.storage_class & STC.return_) &&
-                fd.setUnsafe())
+            if (va && va.isScope() && va.storage_class & STC.return_ && !(v.storage_class & STC.return_))
             {
                 // va may return its value, but v does not allow that, so this is an error
-                if (!gag)
-                    error(ae.loc, "scope variable `%s` assigned to return scope `%s`", v.toChars(), va.toChars());
-                result = true;
-                continue;
+                if (sc.setUnsafeDIP1000(gag, ae.loc, "scope variable `%s` assigned to return scope `%s`", v, va))
+                {
+                    result = true;
+                    continue;
+                }
             }
 
             // If va's lifetime encloses v's, then error
             if (va && !va.isDataseg() &&
-                ((va.enclosesLifetimeOf(v) && !(v.storage_class & STC.temp)) || vaIsRef) &&
-                fd.setUnsafe())
+                ((va.enclosesLifetimeOf(v) && !(v.storage_class & STC.temp)) || vaIsRef))
             {
-                if (!gag)
-                    error(ae.loc, "scope variable `%s` assigned to `%s` with longer lifetime", v.toChars(), va.toChars());
-                result = true;
-                continue;
+                if (sc.setUnsafeDIP1000(gag, ae.loc, "scope variable `%s` assigned to `%s` with longer lifetime", v, va))
+                {
+                    result = true;
+                    continue;
+                }
             }
 
             if (va && !va.isDataseg() && !va.doNotInferScope)
@@ -733,12 +733,7 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag, bool byRef)
                 }
                 continue;
             }
-            if (fd.setUnsafe())
-            {
-                if (!gag)
-                    error(ae.loc, "scope variable `%s` assigned to non-scope `%s`", v.toChars(), e1.toChars());
-                result = true;
-            }
+            result |= sc.setUnsafeDIP1000(gag, ae.loc, "scope variable `%s` assigned to non-scope `%s`", v, e1);
         }
         else if (v.storage_class & STC.variadic && p == fd)
         {
@@ -753,12 +748,7 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag, bool byRef)
                     }
                     continue;
                 }
-                if (fd.setUnsafe())
-                {
-                    if (!gag)
-                        error(ae.loc, "variadic variable `%s` assigned to non-scope `%s`", v.toChars(), e1.toChars());
-                    result = true;
-                }
+                result |= sc.setUnsafeDIP1000(gag, ae.loc, "variadic variable `%s` assigned to non-scope `%s`", v, e1);
             }
         }
         else
@@ -777,27 +767,22 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag, bool byRef)
         if (v.isDataseg())
             continue;
 
-        if (global.params.useDIP1000 != FeatureState.disabled)
+        if (checkScopeVarAddr(v, ae, sc, gag))
         {
-            if (va && va.isScope() && !v.isReference())
-            {
-                if (!(va.storage_class & STC.return_))
-                {
-                    va.doNotInferReturn = true;
-                }
-                else if (setUnsafeDIP1000(fd))
-                {
-                    if (!gag)
-                        previewErrorFunc(sc.isDeprecated(), global.params.useDIP1000)
-                            (ae.loc, "address of local variable `%s` assigned to return scope `%s`", v.toChars(), va.toChars());
-
+            result = true;
+            continue;
+        }
 
-                    if (global.params.useDIP1000 == FeatureState.enabled)
-                    {
-                        result = true;
-                        continue;
-                    }
-                }
+        if (va && va.isScope() && !v.isReference())
+        {
+            if (!(va.storage_class & STC.return_))
+            {
+                va.doNotInferReturn = true;
+            }
+            else
+            {
+                result |= sc.setUnsafeDIP1000(gag, ae.loc,
+                    "address of local variable `%s` assigned to return scope `%s`", v, va);
             }
         }
 
@@ -815,19 +800,19 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag, bool byRef)
         // If va's lifetime encloses v's, then error
         if (va &&
             !(vaIsFirstRef && (v.storage_class & STC.return_)) &&
-            (va.enclosesLifetimeOf(v) || (va.isReference() && !(va.storage_class & STC.temp)) || va.isDataseg()) &&
-            fd.setUnsafe())
+            (va.enclosesLifetimeOf(v) || (va.isReference() && !(va.storage_class & STC.temp)) || va.isDataseg()))
         {
-            if (!gag)
-                error(ae.loc, "address of variable `%s` assigned to `%s` with longer lifetime", v.toChars(), va.toChars());
-            result = true;
-            continue;
+            if (sc.setUnsafeDIP1000(gag, ae.loc, "address of variable `%s` assigned to `%s` with longer lifetime", v, va))
+            {
+                result = true;
+                continue;
+            }
         }
 
         if (!(va && va.isScope()))
             notMaybeScope(v);
 
-        if ((global.params.useDIP1000 != FeatureState.enabled && v.isReference()) || p != sc.func)
+        if (p != sc.func)
             continue;
 
         if (va && !va.isDataseg() && !va.doNotInferScope)
@@ -842,12 +827,8 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag, bool byRef)
         }
         if (e1.op == EXP.structLiteral)
             continue;
-        if (fd.setUnsafe())
-        {
-            if (!gag)
-                error(ae.loc, "reference to local variable `%s` assigned to non-scope `%s`", v.toChars(), e1.toChars());
-            result = true;
-        }
+
+        result |= sc.setUnsafeDIP1000(gag, ae.loc, "reference to local variable `%s` assigned to non-scope `%s`", v, e1);
     }
 
     foreach (FuncDeclaration func; er.byfunc)
@@ -886,12 +867,8 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag, bool byRef)
                     //va.storage_class |= STC.scope_ | STC.scopeinferred;
                 continue;
             }
-            if (fd.setUnsafe())
-            {
-                if (!gag)
-                    error(ae.loc, "reference to local `%s` assigned to non-scope `%s` in @safe code", v.toChars(), e1.toChars());
-                result = true;
-            }
+            result |= sc.setUnsafeDIP1000(gag, ae.loc,
+                "reference to local `%s` assigned to non-scope `%s` in @safe code", v, e1);
         }
     }
 
@@ -912,25 +889,23 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag, bool byRef)
         }
 
         if (ee.op == EXP.call && ee.type.toBasetype().isTypeStruct() &&
-            (!va || !(va.storage_class & STC.temp)) &&
-            fd.setUnsafe())
+            (!va || !(va.storage_class & STC.temp)))
         {
-            if (!gag)
-                error(ee.loc, "address of struct temporary returned by `%s` assigned to longer lived variable `%s`",
-                    ee.toChars(), e1.toChars());
-            result = true;
-            continue;
+            if (sc.setUnsafeDIP1000(gag, ee.loc, "address of struct temporary returned by `%s` assigned to longer lived variable `%s`", ee, e1))
+            {
+                result = true;
+                continue;
+            }
         }
 
         if (ee.op == EXP.structLiteral &&
-            (!va || !(va.storage_class & STC.temp)) &&
-            fd.setUnsafe())
+            (!va || !(va.storage_class & STC.temp)))
         {
-            if (!gag)
-                error(ee.loc, "address of struct literal `%s` assigned to longer lived variable `%s`",
-                    ee.toChars(), e1.toChars());
-            result = true;
-            continue;
+            if (sc.setUnsafeDIP1000(gag, ee.loc, "address of struct literal `%s` assigned to longer lived variable `%s`", ee, e1))
+            {
+                result = true;
+                continue;
+            }
         }
 
         if (va && !va.isDataseg() && !va.doNotInferScope)
@@ -942,13 +917,8 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag, bool byRef)
             continue;
         }
 
-        if (fd.setUnsafe())
-        {
-            if (!gag)
-                error(ee.loc, "reference to stack allocated value returned by `%s` assigned to non-scope `%s`",
-                    ee.toChars(), e1.toChars());
-            result = true;
-        }
+        result |= sc.setUnsafeDIP1000(gag, ee.loc,
+            "reference to stack allocated value returned by `%s` assigned to non-scope `%s`", ee, e1);
     }
 
     return result;
@@ -985,11 +955,8 @@ bool checkThrowEscape(Scope* sc, Expression e, bool gag)
         if (v.isScope() && !v.iscatchvar)       // special case: allow catch var to be rethrown
                                                 // despite being `scope`
         {
-            if (!gag)
-                previewErrorFunc(sc.isDeprecated(), global.params.useDIP1000)
-                                (e.loc, "scope variable `%s` may not be thrown", v.toChars());
-            if (global.params.useDIP1000 == FeatureState.enabled) // https://issues.dlang.org/show_bug.cgi?id=17029
-                result = true;
+            // https://issues.dlang.org/show_bug.cgi?id=17029
+            result |= sc.setUnsafeDIP1000(gag, e.loc, "scope variable `%s` may not be thrown", v);
             continue;
         }
         else
@@ -1050,16 +1017,8 @@ bool checkNewEscape(Scope* sc, Expression e, bool gag)
                  */
                 !(p.parent == sc.func))
             {
-                if (setUnsafeDIP1000(sc.func))     // https://issues.dlang.org/show_bug.cgi?id=20868
-                {
-                    // Only look for errors if in module listed on command line
-                    if (!gag)
-                        previewErrorFunc(sc.isDeprecated(), global.params.useDIP1000)
-                                        (e.loc, "scope variable `%s` may not be copied into allocated memory", v.toChars());
-                    if (global.params.useDIP1000 == FeatureState.enabled)
-                        result = true;
-                }
-
+                // https://issues.dlang.org/show_bug.cgi?id=20868
+                result |= sc.setUnsafeDIP1000(gag, e.loc, "scope variable `%s` may not be copied into allocated memory", v);
                 continue;
             }
         }
@@ -1068,9 +1027,8 @@ bool checkNewEscape(Scope* sc, Expression e, bool gag)
             Type tb = v.type.toBasetype();
             if (tb.ty == Tarray || tb.ty == Tsarray)
             {
-                if (!gag)
-                    error(e.loc, "copying `%s` into allocated memory escapes a reference to variadic parameter `%s`", e.toChars(), v.toChars());
-                result = false;
+                result |= sc.setUnsafeDIP1000(gag, e.loc,
+                    "copying `%s` into allocated memory escapes a reference to variadic parameter `%s`", e, v);
             }
         }
         else
@@ -1085,16 +1043,13 @@ bool checkNewEscape(Scope* sc, Expression e, bool gag)
         if (log) printf("byref `%s`\n", v.toChars());
 
         // 'featureState' tells us whether to emit an error or a deprecation,
-        // depending on the flag passed to the CLI for DIP25
-        void escapingRef(VarDeclaration v, FeatureState featureState = FeatureState.enabled)
+        // depending on the flag passed to the CLI for DIP25 / DIP1000
+        bool escapingRef(VarDeclaration v, FeatureState fs)
         {
-            if (!gag)
-            {
-                const(char)* kind = (v.storage_class & STC.parameter) ? "parameter" : "local";
-                const(char)* msg = "copying `%s` into allocated memory escapes a reference to %s variable `%s`";
-                previewErrorFunc(sc.isDeprecated(), featureState)(e.loc, msg, e.toChars(), kind, v.toChars());
-            }
-            result |= (featureState == FeatureState.enabled);
+            const(char)* msg = v.isParameter() ?
+                "copying `%s` into allocated memory escapes a reference to parameter `%s`" :
+                "copying `%s` into allocated memory escapes a reference to local variable `%s`";
+            return sc.setUnsafePreview(fs, gag, e.loc, msg, e, v);
         }
 
         if (v.isDataseg())
@@ -1106,7 +1061,7 @@ bool checkNewEscape(Scope* sc, Expression e, bool gag)
         {
             if (p == sc.func)
             {
-                escapingRef(v);
+                result |= escapingRef(v, global.params.useDIP1000);
                 continue;
             }
         }
@@ -1122,7 +1077,7 @@ bool checkNewEscape(Scope* sc, Expression e, bool gag)
         {
             //printf("escaping reference to local ref variable %s\n", v.toChars());
             //printf("storage class = x%llx\n", v.storage_class);
-            escapingRef(v, global.params.useDIP25);
+            result |= escapingRef(v, global.params.useDIP25);
             continue;
         }
         // Don't need to be concerned if v's parent does not return a ref
@@ -1269,14 +1224,7 @@ private bool checkReturnEscapeImpl(Scope* sc, Expression e, bool refs, bool gag)
                )
             {
                 // https://issues.dlang.org/show_bug.cgi?id=17029
-                if (setUnsafeDIP1000(sc.func))
-                {
-                    if (!gag)
-                        previewErrorFunc(sc.isDeprecated(), global.params.useDIP1000)
-                                        (e.loc, "scope variable `%s` may not be returned", v.toChars());
-                    if (global.params.useDIP1000 == FeatureState.enabled)
-                        result = true;
-                }
+                result |= sc.setUnsafeDIP1000(gag, e.loc, "scope variable `%s` may not be returned", v);
                 continue;
             }
         }
@@ -1306,16 +1254,18 @@ private bool checkReturnEscapeImpl(Scope* sc, Expression e, bool refs, bool gag)
 
         // 'featureState' tells us whether to emit an error or a deprecation,
         // depending on the flag passed to the CLI for DIP25
-        void escapingRef(VarDeclaration v, ScopeRef vsr, FeatureState featureState = FeatureState.enabled)
+        void escapingRef(VarDeclaration v, FeatureState featureState)
         {
-            if (!gag)
-            {
-                const(char)* varKind = v.isParameter() ? "parameter" : "local variable";
-                previewErrorFunc(sc.isDeprecated(), featureState)(e.loc,
-                    "returning `%s` escapes a reference to %s `%s`", e.toChars(), varKind, v.toChars());
+            const(char)* msg = v.isParameter() ?
+                "returning `%s` escapes a reference to parameter `%s`" :
+                "returning `%s` escapes a reference to local variable `%s`";
 
-                if (v.isParameter() && v.isReference())
+            if (v.isParameter() && v.isReference())
+            {
+                if (sc.setUnsafePreview(featureState, gag, e.loc, msg, e, v) ||
+                    sc.func.isSafeBypassingInference())
                 {
+                    result = true;
                     if (v.storage_class & STC.returnScope)
                     {
                         previewSupplementalFunc(sc.isDeprecated(), featureState)(v.loc,
@@ -1329,7 +1279,12 @@ private bool checkReturnEscapeImpl(Scope* sc, Expression e, bool refs, bool gag)
                     }
                 }
             }
-            result = true;
+            else
+            {
+                if (!gag)
+                    previewErrorFunc(sc.isDeprecated(), featureState)(e.loc, msg, e.toChars(), v.toChars());
+                result = true;
+            }
         }
 
         if (v.isDataseg())
@@ -1340,14 +1295,23 @@ private bool checkReturnEscapeImpl(Scope* sc, Expression e, bool refs, bool gag)
         Dsymbol p = v.toParent2();
 
         // https://issues.dlang.org/show_bug.cgi?id=19965
-        if (!refs && sc.func.vthis == v)
-            notMaybeScope(v);
+        if (!refs)
+        {
+            if (sc.func.vthis == v)
+                notMaybeScope(v);
+
+            if (checkScopeVarAddr(v, e, sc, gag))
+            {
+                result = true;
+                continue;
+            }
+        }
 
         if (!v.isReference())
         {
             if (p == sc.func)
             {
-                escapingRef(v, vsr, FeatureState.enabled);
+                escapingRef(v, FeatureState.enabled);
                 continue;
             }
             FuncDeclaration fd = p.isFuncDeclaration();
@@ -1388,7 +1352,7 @@ private bool checkReturnEscapeImpl(Scope* sc, Expression e, bool refs, bool gag)
                 {
                     //printf("escaping reference to local ref variable %s\n", v.toChars());
                     //printf("storage class = x%llx\n", v.storage_class);
-                    escapingRef(v, vsr, global.params.useDIP25);
+                    escapingRef(v, global.params.useDIP25);
                     continue;
                 }
                 // Don't need to be concerned if v's parent does not return a ref
@@ -1489,370 +1453,385 @@ private void inferReturn(FuncDeclaration fd, VarDeclaration v, bool returnScope)
 void escapeByValue(Expression e, EscapeByResults* er, bool live = false)
 {
     //printf("[%s] escapeByValue, e: %s\n", e.loc.toChars(), e.toChars());
-    extern (C++) final class EscapeVisitor : Visitor
-    {
-        alias visit = Visitor.visit;
-    public:
-        EscapeByResults* er;
-        bool live;
-
-        extern (D) this(EscapeByResults* er, bool live)
-        {
-            this.er = er;
-            this.live = live;
-        }
 
-        override void visit(Expression e)
-        {
-        }
+    void visit(Expression e)
+    {
+    }
 
-        override void visit(AddrExp e)
-        {
-            /* Taking the address of struct literal is normally not
-             * allowed, but CTFE can generate one out of a new expression,
-             * but it'll be placed in static data so no need to check it.
-             */
-            if (e.e1.op != EXP.structLiteral)
-                escapeByRef(e.e1, er, live);
-        }
+    void visitAddr(AddrExp e)
+    {
+        /* Taking the address of struct literal is normally not
+         * allowed, but CTFE can generate one out of a new expression,
+         * but it'll be placed in static data so no need to check it.
+         */
+        if (e.e1.op != EXP.structLiteral)
+            escapeByRef(e.e1, er, live);
+    }
 
-        override void visit(SymOffExp e)
-        {
-            VarDeclaration v = e.var.isVarDeclaration();
-            if (v)
-                er.byref.push(v);
-        }
+    void visitSymOff(SymOffExp e)
+    {
+        VarDeclaration v = e.var.isVarDeclaration();
+        if (v)
+            er.byref.push(v);
+    }
 
-        override void visit(VarExp e)
+    void visitVar(VarExp e)
+    {
+        if (auto v = e.var.isVarDeclaration())
         {
-            if (auto v = e.var.isVarDeclaration())
-            {
-                if (v.type.hasPointers() || // not tracking non-pointers
-                    v.storage_class & STC.lazy_) // lazy variables are actually pointers
-                    er.byvalue.push(v);
-            }
+            if (v.type.hasPointers() || // not tracking non-pointers
+                v.storage_class & STC.lazy_) // lazy variables are actually pointers
+                er.byvalue.push(v);
         }
+    }
 
-        override void visit(ThisExp e)
-        {
-            if (e.var)
-                er.byvalue.push(e.var);
-        }
+    void visitThis(ThisExp e)
+    {
+        if (e.var)
+            er.byvalue.push(e.var);
+    }
 
-        override void visit(PtrExp e)
-        {
-            if (live && e.type.hasPointers())
-                e.e1.accept(this);
-        }
+    void visitPtr(PtrExp e)
+    {
+        if (live && e.type.hasPointers())
+            escapeByValue(e.e1, er, live);
+    }
 
-        override void visit(DotVarExp e)
+    void visitDotVar(DotVarExp e)
+    {
+        auto t = e.e1.type.toBasetype();
+        if (e.type.hasPointers() && (live || t.ty == Tstruct))
         {
-            auto t = e.e1.type.toBasetype();
-            if (e.type.hasPointers() && (live || t.ty == Tstruct))
-            {
-                e.e1.accept(this);
-            }
+            escapeByValue(e.e1, er, live);
         }
+    }
 
-        override void visit(DelegateExp e)
-        {
-            Type t = e.e1.type.toBasetype();
-            if (t.ty == Tclass || t.ty == Tpointer)
-                escapeByValue(e.e1, er, live);
-            else
-                escapeByRef(e.e1, er, live);
-            er.byfunc.push(e.func);
-        }
+    void visitDelegate(DelegateExp e)
+    {
+        Type t = e.e1.type.toBasetype();
+        if (t.ty == Tclass || t.ty == Tpointer)
+            escapeByValue(e.e1, er, live);
+        else
+            escapeByRef(e.e1, er, live);
+        er.byfunc.push(e.func);
+    }
 
-        override void visit(FuncExp e)
-        {
-            if (e.fd.tok == TOK.delegate_)
-                er.byfunc.push(e.fd);
-        }
+    void visitFunc(FuncExp e)
+    {
+        if (e.fd.tok == TOK.delegate_)
+            er.byfunc.push(e.fd);
+    }
 
-        override void visit(TupleExp e)
-        {
-            assert(0); // should have been lowered by now
-        }
+    void visitTuple(TupleExp e)
+    {
+        assert(0); // should have been lowered by now
+    }
 
-        override void visit(ArrayLiteralExp e)
+    void visitArrayLiteral(ArrayLiteralExp e)
+    {
+        Type tb = e.type.toBasetype();
+        if (tb.ty == Tsarray || tb.ty == Tarray)
         {
-            Type tb = e.type.toBasetype();
-            if (tb.ty == Tsarray || tb.ty == Tarray)
+            if (e.basis)
+                escapeByValue(e.basis, er, live);
+            foreach (el; *e.elements)
             {
-                if (e.basis)
-                    e.basis.accept(this);
-                foreach (el; *e.elements)
-                {
-                    if (el)
-                        el.accept(this);
-                }
+                if (el)
+                    escapeByValue(el, er, live);
             }
         }
+    }
 
-        override void visit(StructLiteralExp e)
+    void visitStructLiteral(StructLiteralExp e)
+    {
+        if (e.elements)
         {
-            if (e.elements)
+            foreach (ex; *e.elements)
             {
-                foreach (ex; *e.elements)
-                {
-                    if (ex)
-                        ex.accept(this);
-                }
+                if (ex)
+                    escapeByValue(ex, er, live);
             }
         }
+    }
 
-        override void visit(NewExp e)
+    void visitNew(NewExp e)
+    {
+        Type tb = e.newtype.toBasetype();
+        if (tb.ty == Tstruct && !e.member && e.arguments)
         {
-            Type tb = e.newtype.toBasetype();
-            if (tb.ty == Tstruct && !e.member && e.arguments)
+            foreach (ex; *e.arguments)
             {
-                foreach (ex; *e.arguments)
-                {
-                    if (ex)
-                        ex.accept(this);
-                }
+                if (ex)
+                    escapeByValue(ex, er, live);
             }
         }
+    }
 
-        override void visit(CastExp e)
+    void visitCast(CastExp e)
+    {
+        if (!e.type.hasPointers())
+            return;
+        Type tb = e.type.toBasetype();
+        if (tb.ty == Tarray && e.e1.type.toBasetype().ty == Tsarray)
         {
-            if (!e.type.hasPointers())
-                return;
-            Type tb = e.type.toBasetype();
-            if (tb.ty == Tarray && e.e1.type.toBasetype().ty == Tsarray)
-            {
-                escapeByRef(e.e1, er, live);
-            }
-            else
-                e.e1.accept(this);
+            escapeByRef(e.e1, er, live);
         }
+        else
+            escapeByValue(e.e1, er, live);
+    }
 
-        override void visit(SliceExp e)
+    void visitSlice(SliceExp e)
+    {
+        if (auto ve = e.e1.isVarExp())
         {
-            if (auto ve = e.e1.isVarExp())
+            VarDeclaration v = ve.var.isVarDeclaration();
+            Type tb = e.type.toBasetype();
+            if (v)
             {
-                VarDeclaration v = ve.var.isVarDeclaration();
-                Type tb = e.type.toBasetype();
-                if (v)
+                if (tb.ty == Tsarray)
+                    return;
+                if (v.storage_class & STC.variadic)
                 {
-                    if (tb.ty == Tsarray)
-                        return;
-                    if (v.storage_class & STC.variadic)
-                    {
-                        er.byvalue.push(v);
-                        return;
-                    }
+                    er.byvalue.push(v);
+                    return;
                 }
             }
-            Type t1b = e.e1.type.toBasetype();
-            if (t1b.ty == Tsarray)
-            {
-                Type tb = e.type.toBasetype();
-                if (tb.ty != Tsarray)
-                    escapeByRef(e.e1, er, live);
-            }
-            else
-                e.e1.accept(this);
-        }
-
-        override void visit(IndexExp e)
-        {
-            if (e.e1.type.toBasetype().ty == Tsarray ||
-                live && e.type.hasPointers())
-            {
-                e.e1.accept(this);
-            }
         }
-
-        override void visit(BinExp e)
+        Type t1b = e.e1.type.toBasetype();
+        if (t1b.ty == Tsarray)
         {
             Type tb = e.type.toBasetype();
-            if (tb.ty == Tpointer)
-            {
-                e.e1.accept(this);
-                e.e2.accept(this);
-            }
+            if (tb.ty != Tsarray)
+                escapeByRef(e.e1, er, live);
         }
+        else
+            escapeByValue(e.e1, er, live);
+    }
 
-        override void visit(BinAssignExp e)
+    void visitIndex(IndexExp e)
+    {
+        if (e.e1.type.toBasetype().ty == Tsarray ||
+            live && e.type.hasPointers())
         {
-            e.e1.accept(this);
+            escapeByValue(e.e1, er, live);
         }
+    }
 
-        override void visit(AssignExp e)
+    void visitBin(BinExp e)
+    {
+        Type tb = e.type.toBasetype();
+        if (tb.ty == Tpointer)
         {
-            e.e1.accept(this);
+            escapeByValue(e.e1, er, live);
+            escapeByValue(e.e2, er, live);
         }
+    }
 
-        override void visit(CommaExp e)
-        {
-            e.e2.accept(this);
-        }
+    void visitBinAssign(BinAssignExp e)
+    {
+        escapeByValue(e.e1, er, live);
+    }
 
-        override void visit(CondExp e)
+    void visitAssign(AssignExp e)
+    {
+        escapeByValue(e.e1, er, live);
+    }
+
+    void visitComma(CommaExp e)
+    {
+        escapeByValue(e.e2, er, live);
+    }
+
+    void visitCond(CondExp e)
+    {
+        escapeByValue(e.e1, er, live);
+        escapeByValue(e.e2, er, live);
+    }
+
+    void visitCall(CallExp e)
+    {
+        //printf("CallExp(): %s\n", e.toChars());
+        /* Check each argument that is
+         * passed as 'return scope'.
+         */
+        Type t1 = e.e1.type.toBasetype();
+        TypeFunction tf;
+        TypeDelegate dg;
+        if (t1.ty == Tdelegate)
         {
-            e.e1.accept(this);
-            e.e2.accept(this);
+            dg = t1.isTypeDelegate();
+            tf = dg.next.isTypeFunction();
         }
+        else if (t1.ty == Tfunction)
+            tf = t1.isTypeFunction();
+        else
+            return;
+
+        if (!e.type.hasPointers())
+            return;
 
-        override void visit(CallExp e)
+        if (e.arguments && e.arguments.dim)
         {
-            //printf("CallExp(): %s\n", e.toChars());
-            /* Check each argument that is
-             * passed as 'return scope'.
+            /* j=1 if _arguments[] is first argument,
+             * skip it because it is not passed by ref
              */
-            Type t1 = e.e1.type.toBasetype();
-            TypeFunction tf;
-            TypeDelegate dg;
-            if (t1.ty == Tdelegate)
+            int j = tf.isDstyleVariadic();
+            for (size_t i = j; i < e.arguments.dim; ++i)
             {
-                dg = t1.isTypeDelegate();
-                tf = dg.next.isTypeFunction();
-            }
-            else if (t1.ty == Tfunction)
-                tf = t1.isTypeFunction();
-            else
-                return;
-
-            if (!e.type.hasPointers())
-                return;
-
-            if (e.arguments && e.arguments.dim)
-            {
-                /* j=1 if _arguments[] is first argument,
-                 * skip it because it is not passed by ref
-                 */
-                int j = tf.isDstyleVariadic();
-                for (size_t i = j; i < e.arguments.dim; ++i)
+                Expression arg = (*e.arguments)[i];
+                size_t nparams = tf.parameterList.length;
+                if (i - j < nparams && i >= j)
                 {
-                    Expression arg = (*e.arguments)[i];
-                    size_t nparams = tf.parameterList.length;
-                    if (i - j < nparams && i >= j)
+                    Parameter p = tf.parameterList[i - j];
+                    const stc = tf.parameterStorageClass(null, p);
+                    ScopeRef psr = buildScopeRef(stc);
+                    if (psr == ScopeRef.ReturnScope || psr == ScopeRef.Ref_ReturnScope)
+                        escapeByValue(arg, er, live);
+                    else if (psr == ScopeRef.ReturnRef || psr == ScopeRef.ReturnRef_Scope)
                     {
-                        Parameter p = tf.parameterList[i - j];
-                        const stc = tf.parameterStorageClass(null, p);
-                        ScopeRef psr = buildScopeRef(stc);
-                        if (psr == ScopeRef.ReturnScope || psr == ScopeRef.Ref_ReturnScope)
-                            arg.accept(this);
-                        else if (psr == ScopeRef.ReturnRef || psr == ScopeRef.ReturnRef_Scope)
+                        if (tf.isref)
                         {
-                            if (tf.isref)
-                            {
-                                /* Treat:
-                                 *   ref P foo(return ref P p)
-                                 * as:
-                                 *   p;
-                                 */
-                                arg.accept(this);
-                            }
-                            else
-                                escapeByRef(arg, er, live);
+                            /* Treat:
+                             *   ref P foo(return ref P p)
+                             * as:
+                             *   p;
+                             */
+                            escapeByValue(arg, er, live);
                         }
+                        else
+                            escapeByRef(arg, er, live);
                     }
                 }
             }
-            // If 'this' is returned, check it too
-            if (e.e1.op == EXP.dotVariable && t1.ty == Tfunction)
+        }
+        // If 'this' is returned, check it too
+        if (e.e1.op == EXP.dotVariable && t1.ty == Tfunction)
+        {
+            DotVarExp dve = e.e1.isDotVarExp();
+            FuncDeclaration fd = dve.var.isFuncDeclaration();
+            if (global.params.useDIP1000 == FeatureState.enabled)
             {
-                DotVarExp dve = e.e1.isDotVarExp();
-                FuncDeclaration fd = dve.var.isFuncDeclaration();
-                if (global.params.useDIP1000 == FeatureState.enabled)
+                if (fd && fd.isThis())
                 {
-                   if (fd && fd.isThis())
-                   {
-                        /* Calling a non-static member function dve.var, which is returning `this`, and with dve.e1 representing `this`
-                         */
-
-                        /*****************************
-                         * Concoct storage class for member function's implicit `this` parameter.
-                         * Params:
-                         *      fd = member function
-                         * Returns:
-                         *      storage class for fd's `this`
-                         */
-                        StorageClass getThisStorageClass(FuncDeclaration fd)
-                        {
-                            StorageClass stc;
-                            auto tf = fd.type.toBasetype().isTypeFunction();
-                            if (tf.isreturn)
-                                stc |= STC.return_;
-                            if (tf.isreturnscope)
-                                stc |= STC.returnScope;
-                            auto ad = fd.isThis();
-                            if (ad.isClassDeclaration() || tf.isScopeQual)
-                                stc |= STC.scope_;
-                            if (ad.isStructDeclaration())
-                                stc |= STC.ref_;        // `this` for a struct member function is passed by `ref`
-                            return stc;
-                        }
+                    /* Calling a non-static member function dve.var, which is returning `this`, and with dve.e1 representing `this`
+                     */
 
-                        const psr = buildScopeRef(getThisStorageClass(fd));
-                        if (psr == ScopeRef.ReturnScope || psr == ScopeRef.Ref_ReturnScope)
-                            dve.e1.accept(this);
-                        else if (psr == ScopeRef.ReturnRef || psr == ScopeRef.ReturnRef_Scope)
-                        {
-                            if (tf.isref)
-                            {
-                                /* Treat calling:
-                                 *   struct S { ref S foo() return; }
-                                 * as:
-                                 *   this;
-                                 */
-                                dve.e1.accept(this);
-                            }
-                            else
-                                escapeByRef(dve.e1, er, live);
-                        }
+                    /*****************************
+                     * Concoct storage class for member function's implicit `this` parameter.
+                     * Params:
+                     *      fd = member function
+                     * Returns:
+                     *      storage class for fd's `this`
+                     */
+                    StorageClass getThisStorageClass(FuncDeclaration fd)
+                    {
+                        StorageClass stc;
+                        auto tf = fd.type.toBasetype().isTypeFunction();
+                        if (tf.isreturn)
+                            stc |= STC.return_;
+                        if (tf.isreturnscope)
+                            stc |= STC.returnScope;
+                        auto ad = fd.isThis();
+                        if (ad.isClassDeclaration() || tf.isScopeQual)
+                            stc |= STC.scope_;
+                        if (ad.isStructDeclaration())
+                            stc |= STC.ref_;        // `this` for a struct member function is passed by `ref`
+                        return stc;
                     }
-                }
-                else
-                {
-                    // Calling member function before dip1000
-                    StorageClass stc = dve.var.storage_class & (STC.return_ | STC.scope_ | STC.ref_);
-                    if (tf.isreturn)
-                        stc |= STC.return_;
 
-                    const psr = buildScopeRef(stc);
+                    const psr = buildScopeRef(getThisStorageClass(fd));
                     if (psr == ScopeRef.ReturnScope || psr == ScopeRef.Ref_ReturnScope)
-                        dve.e1.accept(this);
+                        escapeByValue(dve.e1, er, live);
                     else if (psr == ScopeRef.ReturnRef || psr == ScopeRef.ReturnRef_Scope)
-                        escapeByRef(dve.e1, er, live);
+                    {
+                        if (tf.isref)
+                        {
+                            /* Treat calling:
+                             *   struct S { ref S foo() return; }
+                             * as:
+                             *   this;
+                             */
+                            escapeByValue(dve.e1, er, live);
+                        }
+                        else
+                            escapeByRef(dve.e1, er, live);
+                    }
                 }
+            }
+            else
+            {
+                // Calling member function before dip1000
+                StorageClass stc = dve.var.storage_class & (STC.return_ | STC.scope_ | STC.ref_);
+                if (tf.isreturn)
+                    stc |= STC.return_;
 
-                // If it's also a nested function that is 'return scope'
-                if (fd && fd.isNested())
-                {
-                    if (tf.isreturn && tf.isScopeQual)
-                        er.byexp.push(e);
-                }
+                const psr = buildScopeRef(stc);
+                if (psr == ScopeRef.ReturnScope || psr == ScopeRef.Ref_ReturnScope)
+                    escapeByValue(dve.e1, er, live);
+                else if (psr == ScopeRef.ReturnRef || psr == ScopeRef.ReturnRef_Scope)
+                    escapeByRef(dve.e1, er, live);
             }
 
-            /* If returning the result of a delegate call, the .ptr
-             * field of the delegate must be checked.
-             */
-            if (dg)
+            // If it's also a nested function that is 'return scope'
+            if (fd && fd.isNested())
             {
-                if (tf.isreturn)
-                    e.e1.accept(this);
+                if (tf.isreturn && tf.isScopeQual)
+                    er.byexp.push(e);
             }
+        }
 
-            /* If it's a nested function that is 'return scope'
-             */
-            if (auto ve = e.e1.isVarExp())
+        /* If returning the result of a delegate call, the .ptr
+         * field of the delegate must be checked.
+         */
+        if (dg)
+        {
+            if (tf.isreturn)
+                escapeByValue(e.e1, er, live);
+        }
+
+        /* If it's a nested function that is 'return scope'
+         */
+        if (auto ve = e.e1.isVarExp())
+        {
+            FuncDeclaration fd = ve.var.isFuncDeclaration();
+            if (fd && fd.isNested())
             {
-                FuncDeclaration fd = ve.var.isFuncDeclaration();
-                if (fd && fd.isNested())
-                {
-                    if (tf.isreturn && tf.isScopeQual)
-                        er.byexp.push(e);
-                }
+                if (tf.isreturn && tf.isScopeQual)
+                    er.byexp.push(e);
             }
         }
     }
 
-    scope EscapeVisitor v = new EscapeVisitor(er, live);
-    e.accept(v);
+    switch (e.op)
+    {
+        case EXP.address: return visitAddr(e.isAddrExp());
+        case EXP.symbolOffset: return visitSymOff(e.isSymOffExp());
+        case EXP.variable: return visitVar(e.isVarExp());
+        case EXP.this_: return visitThis(e.isThisExp());
+        case EXP.star: return visitPtr(e.isPtrExp());
+        case EXP.dotVariable: return visitDotVar(e.isDotVarExp());
+        case EXP.delegate_: return visitDelegate(e.isDelegateExp());
+        case EXP.function_: return visitFunc(e.isFuncExp());
+        case EXP.tuple: return visitTuple(e.isTupleExp());
+        case EXP.arrayLiteral: return visitArrayLiteral(e.isArrayLiteralExp());
+        case EXP.structLiteral: return visitStructLiteral(e.isStructLiteralExp());
+        case EXP.new_: return visitNew(e.isNewExp());
+        case EXP.cast_: return visitCast(e.isCastExp());
+        case EXP.slice: return visitSlice(e.isSliceExp());
+        case EXP.index: return visitIndex(e.isIndexExp());
+        case EXP.blit: return visitAssign(e.isBlitExp());
+        case EXP.construct: return visitAssign(e.isConstructExp());
+        case EXP.assign: return visitAssign(e.isAssignExp());
+        case EXP.comma: return visitComma(e.isCommaExp());
+        case EXP.question: return visitCond(e.isCondExp());
+        case EXP.call: return visitCall(e.isCallExp());
+        default:
+            if (auto b = e.isBinExp())
+                return visitBin(b);
+            if (auto ba = e.isBinAssignExp())
+                return visitBinAssign(ba);
+            return visit(e);
+    }
 }
 
 
@@ -1877,236 +1856,239 @@ void escapeByValue(Expression e, EscapeByResults* er, bool live = false)
 void escapeByRef(Expression e, EscapeByResults* er, bool live = false)
 {
     //printf("[%s] escapeByRef, e: %s\n", e.loc.toChars(), e.toChars());
-    extern (C++) final class EscapeRefVisitor : Visitor
+    void visit(Expression e)
     {
-        alias visit = Visitor.visit;
-    public:
-        EscapeByResults* er;
-        bool live;
-
-        extern (D) this(EscapeByResults* er, bool live)
-        {
-            this.er = er;
-            this.live = live;
-        }
-
-        override void visit(Expression e)
-        {
-        }
+    }
 
-        override void visit(VarExp e)
+    void visitVar(VarExp e)
+    {
+        auto v = e.var.isVarDeclaration();
+        if (v)
         {
-            auto v = e.var.isVarDeclaration();
-            if (v)
+            if (v.storage_class & STC.ref_ && v.storage_class & (STC.foreach_ | STC.temp) && v._init)
             {
-                if (v.storage_class & STC.ref_ && v.storage_class & (STC.foreach_ | STC.temp) && v._init)
+                /* If compiler generated ref temporary
+                    *   (ref v = ex; ex)
+                    * look at the initializer instead
+                    */
+                if (ExpInitializer ez = v._init.isExpInitializer())
                 {
-                    /* If compiler generated ref temporary
-                     *   (ref v = ex; ex)
-                     * look at the initializer instead
-                     */
-                    if (ExpInitializer ez = v._init.isExpInitializer())
-                    {
-                        if (auto ce = ez.exp.isConstructExp())
-                            ce.e2.accept(this);
-                        else
-                            ez.exp.accept(this);
-                    }
+                    if (auto ce = ez.exp.isConstructExp())
+                        escapeByRef(ce.e2, er, live);
+                    else
+                        escapeByRef(ez.exp, er, live);
                 }
-                else
-                    er.byref.push(v);
             }
+            else
+                er.byref.push(v);
         }
+    }
 
-        override void visit(ThisExp e)
-        {
-            if (e.var && e.var.toParent2().isFuncDeclaration().hasDualContext())
-                escapeByValue(e, er, live);
-            else if (e.var)
-                er.byref.push(e.var);
-        }
+    void visitThis(ThisExp e)
+    {
+        if (e.var && e.var.toParent2().isFuncDeclaration().hasDualContext())
+            escapeByValue(e, er, live);
+        else if (e.var)
+            er.byref.push(e.var);
+    }
 
-        override void visit(PtrExp e)
-        {
-            escapeByValue(e.e1, er, live);
-        }
+    void visitPtr(PtrExp e)
+    {
+        escapeByValue(e.e1, er, live);
+    }
 
-        override void visit(IndexExp e)
+    void visitIndex(IndexExp e)
+    {
+        Type tb = e.e1.type.toBasetype();
+        if (auto ve = e.e1.isVarExp())
         {
-            Type tb = e.e1.type.toBasetype();
-            if (auto ve = e.e1.isVarExp())
+            VarDeclaration v = ve.var.isVarDeclaration();
+            if (tb.ty == Tarray || tb.ty == Tsarray)
             {
-                VarDeclaration v = ve.var.isVarDeclaration();
-                if (tb.ty == Tarray || tb.ty == Tsarray)
+                if (v && v.storage_class & STC.variadic)
                 {
-                    if (v && v.storage_class & STC.variadic)
-                    {
-                        er.byref.push(v);
-                        return;
-                    }
+                    er.byref.push(v);
+                    return;
                 }
             }
-            if (tb.ty == Tsarray)
-            {
-                e.e1.accept(this);
-            }
-            else if (tb.ty == Tarray)
-            {
-                escapeByValue(e.e1, er, live);
-            }
         }
-
-        override void visit(StructLiteralExp e)
+        if (tb.ty == Tsarray)
         {
-            if (e.elements)
-            {
-                foreach (ex; *e.elements)
-                {
-                    if (ex)
-                        ex.accept(this);
-                }
-            }
-            er.byexp.push(e);
+            escapeByRef(e.e1, er, live);
         }
-
-        override void visit(DotVarExp e)
+        else if (tb.ty == Tarray)
         {
-            Type t1b = e.e1.type.toBasetype();
-            if (t1b.ty == Tclass)
-                escapeByValue(e.e1, er, live);
-            else
-                e.e1.accept(this);
+            escapeByValue(e.e1, er, live);
         }
+    }
 
-        override void visit(BinAssignExp e)
+    void visitStructLiteral(StructLiteralExp e)
+    {
+        if (e.elements)
         {
-            e.e1.accept(this);
+            foreach (ex; *e.elements)
+            {
+                if (ex)
+                    escapeByRef(ex, er, live);
+            }
         }
+        er.byexp.push(e);
+    }
 
-        override void visit(AssignExp e)
-        {
-            e.e1.accept(this);
-        }
+    void visitDotVar(DotVarExp e)
+    {
+        Type t1b = e.e1.type.toBasetype();
+        if (t1b.ty == Tclass)
+            escapeByValue(e.e1, er, live);
+        else
+            escapeByRef(e.e1, er, live);
+    }
 
-        override void visit(CommaExp e)
-        {
-            e.e2.accept(this);
-        }
+    void visitBinAssign(BinAssignExp e)
+    {
+        escapeByRef(e.e1, er, live);
+    }
 
-        override void visit(CondExp e)
-        {
-            e.e1.accept(this);
-            e.e2.accept(this);
-        }
+    void visitAssign(AssignExp e)
+    {
+        escapeByRef(e.e1, er, live);
+    }
 
-        override void visit(CallExp e)
+    void visitComma(CommaExp e)
+    {
+        escapeByRef(e.e2, er, live);
+    }
+
+    void visitCond(CondExp e)
+    {
+        escapeByRef(e.e1, er, live);
+        escapeByRef(e.e2, er, live);
+    }
+
+    void visitCall(CallExp e)
+    {
+        //printf("escapeByRef.CallExp(): %s\n", e.toChars());
+        /* If the function returns by ref, check each argument that is
+         * passed as 'return ref'.
+         */
+        Type t1 = e.e1.type.toBasetype();
+        TypeFunction tf;
+        if (t1.ty == Tdelegate)
+            tf = t1.isTypeDelegate().next.isTypeFunction();
+        else if (t1.ty == Tfunction)
+            tf = t1.isTypeFunction();
+        else
+            return;
+        if (tf.isref)
         {
-            //printf("escapeByRef.CallExp(): %s\n", e.toChars());
-            /* If the function returns by ref, check each argument that is
-             * passed as 'return ref'.
-             */
-            Type t1 = e.e1.type.toBasetype();
-            TypeFunction tf;
-            if (t1.ty == Tdelegate)
-                tf = t1.isTypeDelegate().next.isTypeFunction();
-            else if (t1.ty == Tfunction)
-                tf = t1.isTypeFunction();
-            else
-                return;
-            if (tf.isref)
+            if (e.arguments && e.arguments.dim)
             {
-                if (e.arguments && e.arguments.dim)
+                /* j=1 if _arguments[] is first argument,
+                 * skip it because it is not passed by ref
+                 */
+                int j = tf.isDstyleVariadic();
+                for (size_t i = j; i < e.arguments.dim; ++i)
                 {
-                    /* j=1 if _arguments[] is first argument,
-                     * skip it because it is not passed by ref
-                     */
-                    int j = tf.isDstyleVariadic();
-                    for (size_t i = j; i < e.arguments.dim; ++i)
+                    Expression arg = (*e.arguments)[i];
+                    size_t nparams = tf.parameterList.length;
+                    if (i - j < nparams && i >= j)
                     {
-                        Expression arg = (*e.arguments)[i];
-                        size_t nparams = tf.parameterList.length;
-                        if (i - j < nparams && i >= j)
+                        Parameter p = tf.parameterList[i - j];
+                        const stc = tf.parameterStorageClass(null, p);
+                        ScopeRef psr = buildScopeRef(stc);
+                        if (psr == ScopeRef.ReturnRef || psr == ScopeRef.ReturnRef_Scope)
+                            escapeByRef(arg, er, live);
+                        else if (psr == ScopeRef.ReturnScope || psr == ScopeRef.Ref_ReturnScope)
                         {
-                            Parameter p = tf.parameterList[i - j];
-                            const stc = tf.parameterStorageClass(null, p);
-                            ScopeRef psr = buildScopeRef(stc);
-                            if (psr == ScopeRef.ReturnRef || psr == ScopeRef.ReturnRef_Scope)
-                                arg.accept(this);
-                            else if (psr == ScopeRef.ReturnScope || psr == ScopeRef.Ref_ReturnScope)
+                            if (auto de = arg.isDelegateExp())
                             {
-                                if (auto de = arg.isDelegateExp())
-                                {
-                                    if (de.func.isNested())
-                                        er.byexp.push(de);
-                                }
-                                else
-                                    escapeByValue(arg, er, live);
+                                if (de.func.isNested())
+                                    er.byexp.push(de);
                             }
+                            else
+                                escapeByValue(arg, er, live);
                         }
                     }
                 }
-                // If 'this' is returned by ref, check it too
-                if (e.e1.op == EXP.dotVariable && t1.ty == Tfunction)
+            }
+            // If 'this' is returned by ref, check it too
+            if (e.e1.op == EXP.dotVariable && t1.ty == Tfunction)
+            {
+                DotVarExp dve = e.e1.isDotVarExp();
+
+                // https://issues.dlang.org/show_bug.cgi?id=20149#c10
+                if (dve.var.isCtorDeclaration())
                 {
-                    DotVarExp dve = e.e1.isDotVarExp();
+                    er.byexp.push(e);
+                    return;
+                }
 
-                    // https://issues.dlang.org/show_bug.cgi?id=20149#c10
-                    if (dve.var.isCtorDeclaration())
-                    {
-                        er.byexp.push(e);
-                        return;
-                    }
+                StorageClass stc = dve.var.storage_class & (STC.return_ | STC.scope_ | STC.ref_);
+                if (tf.isreturn)
+                    stc |= STC.return_;
+                if (tf.isref)
+                    stc |= STC.ref_;
+                if (tf.isScopeQual)
+                    stc |= STC.scope_;
+                if (tf.isreturnscope)
+                    stc |= STC.returnScope;
+
+                const psr = buildScopeRef(stc);
+                if (psr == ScopeRef.ReturnRef || psr == ScopeRef.ReturnRef_Scope)
+                        escapeByRef(dve.e1, er, live);
+                else if (psr == ScopeRef.ReturnScope || psr == ScopeRef.Ref_ReturnScope)
+                        escapeByValue(dve.e1, er, live);
 
-                    StorageClass stc = dve.var.storage_class & (STC.return_ | STC.scope_ | STC.ref_);
-                    if (tf.isreturn)
-                        stc |= STC.return_;
-                    if (tf.isref)
-                        stc |= STC.ref_;
-                    if (tf.isScopeQual)
-                        stc |= STC.scope_;
-                    if (tf.isreturnscope)
-                        stc |= STC.returnScope;
-
-                    const psr = buildScopeRef(stc);
-                    if (psr == ScopeRef.ReturnRef || psr == ScopeRef.ReturnRef_Scope)
-                         dve.e1.accept(this);
-                    else if (psr == ScopeRef.ReturnScope || psr == ScopeRef.Ref_ReturnScope)
-                         escapeByValue(dve.e1, er, live);
-
-                    // If it's also a nested function that is 'return ref'
-                    if (FuncDeclaration fd = dve.var.isFuncDeclaration())
+                // If it's also a nested function that is 'return ref'
+                if (FuncDeclaration fd = dve.var.isFuncDeclaration())
+                {
+                    if (fd.isNested() && tf.isreturn)
                     {
-                        if (fd.isNested() && tf.isreturn)
-                        {
-                            er.byexp.push(e);
-                        }
+                        er.byexp.push(e);
                     }
                 }
-                // If it's a delegate, check it too
-                if (e.e1.op == EXP.variable && t1.ty == Tdelegate)
-                {
-                    escapeByValue(e.e1, er, live);
-                }
+            }
+            // If it's a delegate, check it too
+            if (e.e1.op == EXP.variable && t1.ty == Tdelegate)
+            {
+                escapeByValue(e.e1, er, live);
+            }
 
-                /* If it's a nested function that is 'return ref'
-                 */
-                if (auto ve = e.e1.isVarExp())
+            /* If it's a nested function that is 'return ref'
+             */
+            if (auto ve = e.e1.isVarExp())
+            {
+                FuncDeclaration fd = ve.var.isFuncDeclaration();
+                if (fd && fd.isNested())
                 {
-                    FuncDeclaration fd = ve.var.isFuncDeclaration();
-                    if (fd && fd.isNested())
-                    {
-                        if (tf.isreturn)
-                            er.byexp.push(e);
-                    }
+                    if (tf.isreturn)
+                        er.byexp.push(e);
                 }
             }
-            else
-                er.byexp.push(e);
         }
+        else
+            er.byexp.push(e);
     }
 
-    scope EscapeRefVisitor v = new EscapeRefVisitor(er, live);
-    e.accept(v);
+    switch (e.op)
+    {
+        case EXP.variable: return visitVar(e.isVarExp());
+        case EXP.this_: return visitThis(e.isThisExp());
+        case EXP.star: return visitPtr(e.isPtrExp());
+        case EXP.structLiteral: return visitStructLiteral(e.isStructLiteralExp());
+        case EXP.dotVariable: return visitDotVar(e.isDotVarExp());
+        case EXP.index: return visitIndex(e.isIndexExp());
+        case EXP.blit: return visitAssign(e.isBlitExp());
+        case EXP.construct: return visitAssign(e.isConstructExp());
+        case EXP.assign: return visitAssign(e.isAssignExp());
+        case EXP.comma: return visitComma(e.isCommaExp());
+        case EXP.question: return visitCond(e.isCondExp());
+        case EXP.call: return visitCall(e.isCallExp());
+        default:
+            if (auto ba = e.isBinAssignExp())
+                return visitBinAssign(ba);
+            return visit(e);
+    }
 }
 
 
@@ -2170,7 +2152,7 @@ public void findAllOuterAccessedVariables(FuncDeclaration fd, VarDeclarations* v
  */
 version (none)
 {
-    public void notMaybeScope(string file = __FILE__, int line = __LINE__)(VarDeclaration v)
+    private void notMaybeScope(string file = __FILE__, int line = __LINE__)(VarDeclaration v)
     {
         printf("%.*s(%d): notMaybeScope('%s')\n", cast(int)file.length, file.ptr, line, v.toChars());
         v.storage_class &= ~STC.maybescope;
@@ -2178,12 +2160,88 @@ version (none)
 }
 else
 {
-    public void notMaybeScope(VarDeclaration v)
+    private void notMaybeScope(VarDeclaration v)
     {
         v.storage_class &= ~STC.maybescope;
     }
 }
 
+/***********************************
+ * After semantic analysis of the function body,
+ * try to infer `scope` / `return` on the parameters
+ *
+ * Params:
+ *   funcdecl = function declaration that was analyzed
+ *   f = final function type. `funcdecl.type` started as the 'premature type' before attribute
+ *       inference, then its inferred attributes are copied over to final type `f`
+ */
+void finishScopeParamInference(FuncDeclaration funcdecl, ref TypeFunction f)
+{
+    if (funcdecl.flags & FUNCFLAG.returnInprocess)
+    {
+        funcdecl.flags &= ~FUNCFLAG.returnInprocess;
+        if (funcdecl.storage_class & STC.return_)
+        {
+            if (funcdecl.type == f)
+                f = cast(TypeFunction)f.copy();
+            f.isreturn = true;
+            f.isreturnscope = cast(bool) (funcdecl.storage_class & STC.returnScope);
+            if (funcdecl.storage_class & STC.returninferred)
+                f.isreturninferred = true;
+        }
+    }
+
+    funcdecl.flags &= ~FUNCFLAG.inferScope;
+
+    // Eliminate maybescope's
+    {
+        // Create and fill array[] with maybe candidates from the `this` and the parameters
+        VarDeclaration[10] tmp = void;
+        size_t dim = (funcdecl.vthis !is null) + (funcdecl.parameters ? funcdecl.parameters.dim : 0);
+
+        import dmd.common.string : SmallBuffer;
+        auto sb = SmallBuffer!VarDeclaration(dim, tmp[]);
+        VarDeclaration[] array = sb[];
+
+        size_t n = 0;
+        if (funcdecl.vthis)
+            array[n++] = funcdecl.vthis;
+        if (funcdecl.parameters)
+        {
+            foreach (v; *funcdecl.parameters)
+            {
+                array[n++] = v;
+            }
+        }
+        eliminateMaybeScopes(array[0 .. n]);
+    }
+
+    // Infer STC.scope_
+    if (funcdecl.parameters && !funcdecl.errors)
+    {
+        assert(f.parameterList.length == funcdecl.parameters.dim);
+        foreach (u, p; f.parameterList)
+        {
+            auto v = (*funcdecl.parameters)[u];
+            if (v.storage_class & STC.maybescope)
+            {
+                //printf("Inferring scope for %s\n", v.toChars());
+                notMaybeScope(v);
+                v.storage_class |= STC.scope_ | STC.scopeinferred;
+                p.storageClass |= STC.scope_ | STC.scopeinferred;
+                assert(!(p.storageClass & STC.maybescope));
+            }
+        }
+    }
+
+    if (funcdecl.vthis && funcdecl.vthis.storage_class & STC.maybescope)
+    {
+        notMaybeScope(funcdecl.vthis);
+        funcdecl.vthis.storage_class |= STC.scope_ | STC.scopeinferred;
+        f.isScopeQual = true;
+        f.isscopeinferred = true;
+    }
+}
 
 /**********************************************
  * Have some variables that are maybescopes that were
@@ -2207,7 +2265,7 @@ else
  * Params:
  *      array = array of variables that were assigned to from maybescope variables
  */
-public void eliminateMaybeScopes(VarDeclaration[] array)
+private void eliminateMaybeScopes(VarDeclaration[] array)
 {
     enum log = false;
     if (log) printf("eliminateMaybeScopes()\n");
@@ -2355,10 +2413,89 @@ private void addMaybe(VarDeclaration va, VarDeclaration v)
     va.maybes.push(v);
 }
 
+/***************************************
+ * Like `FuncDeclaration.setUnsafe`, but modified for dip25 / dip1000 by default transitions
+ *
+ * With `-preview=dip1000` it actually sets the function as unsafe / prints an error, while
+ * without it, it only prints a deprecation in a `@safe` function.
+ * With `-revert=preview=dip1000`, it doesn't do anything.
+ *
+ * Params:
+ *   sc = used for checking whether we are in a deprecated scope
+ *   fs = command line setting of dip1000 / dip25
+ *   gag = surpress error message
+ *   loc = location of error
+ *   fmt = printf-style format string
+ *   arg0  = (optional) argument for first %s format specifier
+ *   arg1  = (optional) argument for second %s format specifier
+ * Returns: whether an actual safe error (not deprecation) occured
+ */
+private bool setUnsafePreview(Scope* sc, FeatureState fs, bool gag, Loc loc, const(char)* msg, RootObject arg0 = null, RootObject arg1 = null)
+{
+    if (fs == FeatureState.disabled)
+    {
+        return false;
+    }
+    else if (fs == FeatureState.enabled)
+    {
+        return sc.func.setUnsafe(gag, loc, msg, arg0, arg1);
+    }
+    else
+    {
+        if (sc.func.isSafeBypassingInference())
+        {
+            if (!gag)
+                previewErrorFunc(sc.isDeprecated(), fs)(
+                    loc, msg, arg0 ? arg0.toChars() : "", arg1 ? arg1.toChars() : ""
+                );
+        }
+        return false;
+    }
+}
+
+// `setUnsafePreview` partially evaluated for dip1000
+private bool setUnsafeDIP1000(Scope* sc, bool gag, Loc loc, const(char)* msg, RootObject arg0 = null, RootObject arg1 = null)
+{
+    return setUnsafePreview(sc, global.params.useDIP1000, gag, loc, msg, arg0, arg1);
+}
 
-private bool setUnsafeDIP1000(FuncDeclaration f)
+/***************************************
+ * Check that taking the address of `v` is `@safe`
+ *
+ * It's not possible to take the address of a scope variable, because `scope` only applies
+ * to the top level indirection.
+ *
+ * Params:
+ *     v = variable that a reference is created
+ *     e = expression that takes the referene
+ *     sc = used to obtain function / deprecated status
+ *     gag = don't print errors
+ * Returns:
+ *     true if taking the address of `v` is problematic because of the lack of transitive `scope`
+ */
+private bool checkScopeVarAddr(VarDeclaration v, Expression e, Scope* sc, bool gag)
 {
-    return global.params.useDIP1000 == FeatureState.enabled
-        ? f.setUnsafe()
-        : f.isSafeBypassingInference();
+    if (v.storage_class & STC.temp)
+        return false;
+
+    if (!v.isScope())
+    {
+        v.storage_class &= ~STC.maybescope;
+        v.doNotInferScope = true;
+        return false;
+    }
+
+    if (!e.type)
+        return false;
+
+    // When the type after dereferencing has no pointers, it's okay.
+    // Comes up when escaping `&someStruct.intMember` of a `scope` struct:
+    // scope does not apply to the `int`
+    Type t = e.type.baseElemOf();
+    if ((t.ty == Tarray || t.ty == Tpointer) && !t.nextOf().toBasetype().hasPointers())
+        return false;
+
+    // take address of `scope` variable not allowed, requires transitive scope
+    return sc.setUnsafeDIP1000(gag, e.loc,
+        "cannot take address of `scope` variable `%s` since `scope` applies to first indirection only", v);
 }
index 107e85b07935d5b1a18a37ce6a95bb8505152426..08723565355e231a22b45f5de25b4a6138617f6d 100644 (file)
@@ -1370,10 +1370,9 @@ extern (C++) abstract class Expression : ASTNode
          */
         if (v.storage_class & STC.gshared)
         {
-            if (sc.func.setUnsafe())
+            if (sc.func.setUnsafe(false, this.loc,
+                "`@safe` function `%s` cannot access `__gshared` data `%s`", sc.func, v))
             {
-                error("`@safe` %s `%s` cannot access `__gshared` data `%s`",
-                    sc.func.kind(), sc.func.toChars(), v.toChars());
                 err = true;
             }
         }
@@ -1411,7 +1410,7 @@ extern (C++) abstract class Expression : ASTNode
 
         if (!f.isSafe() && !f.isTrusted())
         {
-            if (sc.flags & SCOPE.compile ? sc.func.isSafeBypassingInference() : sc.func.setUnsafe())
+            if (sc.flags & SCOPE.compile ? sc.func.isSafeBypassingInference() : sc.func.setUnsafeCall(f))
             {
                 if (!loc.isValid()) // e.g. implicitly generated dtor
                     loc = sc.func.loc;
@@ -1420,6 +1419,7 @@ extern (C++) abstract class Expression : ASTNode
                 error("`@safe` %s `%s` cannot call `@system` %s `%s`",
                     sc.func.kind(), sc.func.toPrettyChars(), f.kind(),
                     prettyChars);
+                f.errorSupplementalInferredSafety(/*max depth*/ 10);
                 .errorSupplemental(f.loc, "`%s` is declared here", prettyChars);
 
                 checkOverridenDtor(sc, f, dd => dd.type.toTypeFunction().trust > TRUST.system, "@system");
@@ -1456,7 +1456,8 @@ extern (C++) abstract class Expression : ASTNode
 
                 // Lowered non-@nogc'd hooks will print their own error message inside of nogc.d (NOGCVisitor.visit(CallExp e)),
                 // so don't print anything to avoid double error messages.
-                if (!(f.ident == Id._d_HookTraceImpl || f.ident == Id._d_arraysetlengthT))
+                if (!(f.ident == Id._d_HookTraceImpl || f.ident == Id._d_arraysetlengthT
+                    || f.ident == Id._d_arrayappendT || f.ident == Id._d_arrayappendcTX))
                     error("`@nogc` %s `%s` cannot call non-@nogc %s `%s`",
                         sc.func.kind(), sc.func.toPrettyChars(), f.kind(), f.toPrettyChars());
 
@@ -5760,9 +5761,8 @@ extern (C++) final class DelegatePtrExp : UnaExp
 
     override Expression modifiableLvalue(Scope* sc, Expression e)
     {
-        if (sc.func.setUnsafe())
+        if (sc.func.setUnsafe(false, this.loc, "cannot modify delegate pointer in `@safe` code `%s`", this))
         {
-            error("cannot modify delegate pointer in `@safe` code `%s`", toChars());
             return ErrorExp.get();
         }
         return Expression.modifiableLvalue(sc, e);
@@ -5799,9 +5799,8 @@ extern (C++) final class DelegateFuncptrExp : UnaExp
 
     override Expression modifiableLvalue(Scope* sc, Expression e)
     {
-        if (sc.func.setUnsafe())
+        if (sc.func.setUnsafe(false, this.loc, "cannot modify delegate function pointer in `@safe` code `%s`", this))
         {
-            error("cannot modify delegate function pointer in `@safe` code `%s`", toChars());
             return ErrorExp.get();
         }
         return Expression.modifiableLvalue(sc, e);
index d4e96bb0f090e5a0e56d75b73ddd5e8a8b6c27e2..b65b0ed1375420b13a98bf550f6c52b5ef1efd71 100644 (file)
@@ -1276,7 +1276,7 @@ private Expression resolvePropertiesX(Scope* sc, Expression e1, Expression e2 =
                     // @@@DEPRECATED_2.105@@@
                     // When turning into error, uncomment the return statement
                     TypeFunction tf = fd.type.isTypeFunction();
-                    deprecation(loc, "Function `%s` of type `%s` is not accessible from module `%s`",
+                    deprecation(loc, "function `%s` of type `%s` is not accessible from module `%s`",
                                 fd.toPrettyChars(), tf.toChars, sc._module.toChars);
                     //return ErrorExp.get();
                 }
@@ -1298,7 +1298,7 @@ private Expression resolvePropertiesX(Scope* sc, Expression e1, Expression e2 =
                     {
                         // @@@DEPRECATED_2.105@@@
                         // When turning into error, uncomment the return statement
-                        deprecation(loc, "Function `%s` of type `%s` is not accessible from module `%s`",
+                        deprecation(loc, "function `%s` of type `%s` is not accessible from module `%s`",
                                     fd.toPrettyChars(), tf.toChars, sc._module.toChars);
                         //return ErrorExp.get();
                     }
@@ -2035,20 +2035,26 @@ private bool functionParameters(const ref Loc loc, Scope* sc,
                 /* Argument value can be assigned to firstArg.
                  * Check arg to see if it matters.
                  */
-                if (global.params.useDIP1000 == FeatureState.enabled)
-                    err |= checkParamArgumentReturn(sc, firstArg, arg, p, false);
+                err |= checkParamArgumentReturn(sc, firstArg, arg, p, false);
             }
             // Allow 'lazy' to imply 'scope' - lazy parameters can be passed along
             // as lazy parameters to the next function, but that isn't escaping.
-            else if (!(pStc & (STC.scope_ | STC.lazy_)))
+            else if (!(pStc & STC.lazy_))
             {
                 /* Argument value can escape from the called function.
                  * Check arg to see if it matters.
                  */
-                if (global.params.useDIP1000 == FeatureState.enabled)
-                    err |= checkParamArgumentEscape(sc, fd, p, arg, false, false);
+                err |= checkParamArgumentEscape(sc, fd, p, cast(STC) pStc, arg, false, false);
             }
-            else if (!(pStc & STC.return_))
+
+            // Turning heap allocations into stack allocations is dangerous without dip1000, since `scope` inference
+            // may be unreliable when scope violations only manifest as deprecation warnings.
+            // However, existing `@nogc` code may rely on it, so still do it when the parameter is explicitly marked `scope`
+            const explicitScope = (p.storageClass & STC.lazy_) ||
+                ((p.storageClass & STC.scope_) && !(p.storageClass & STC.scopeinferred));
+            if ((pStc & (STC.scope_ | STC.lazy_)) &&
+                ((global.params.useDIP1000 == FeatureState.enabled) || explicitScope) &&
+                !(pStc & STC.return_))
             {
                 /* Argument value cannot escape from the called function.
                  */
@@ -2058,13 +2064,14 @@ private bool functionParameters(const ref Loc loc, Scope* sc,
 
                 ArrayLiteralExp ale;
                 if (p.type.toBasetype().ty == Tarray &&
-                    (ale = a.isArrayLiteralExp()) !is null)
+                    (ale = a.isArrayLiteralExp()) !is null && ale.elements && ale.elements.length > 0)
                 {
                     // allocate the array literal as temporary static array on the stack
-                    ale.type = ale.type.nextOf().sarrayOf(ale.elements ? ale.elements.length : 0);
+                    ale.type = ale.type.nextOf().sarrayOf(ale.elements.length);
                     auto tmp = copyToTemp(0, "__arrayliteral_on_stack", ale);
                     auto declareTmp = new DeclarationExp(ale.loc, tmp);
-                    auto castToSlice = new CastExp(ale.loc, new VarExp(ale.loc, tmp), p.type);
+                    auto castToSlice = new CastExp(ale.loc, new VarExp(ale.loc, tmp),
+                        p.type.substWildTo(MODFlags.mutable));
                     arg = CommaExp.combine(declareTmp, castToSlice);
                     arg = arg.expressionSemantic(sc);
                 }
@@ -2473,7 +2480,7 @@ Package resolveIsPackage(Dsymbol sym)
     {
         if (imp.pkg is null)
         {
-            .error(sym.loc, "Internal Compiler Error: unable to process forward-referenced import `%s`",
+            .error(sym.loc, "internal compiler error: unable to process forward-referenced import `%s`",
                     imp.toChars());
             assert(0);
         }
@@ -2995,7 +3002,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             buffer.write4(0);
             e.setData(buffer.extractData(), newlen, 4);
             if (sc && sc.flags & SCOPE.Cfile)
-                e.type = Type.tuns32.pointerTo();
+                e.type = Type.tuns32.sarrayOf(e.len + 1);
             else
                 e.type = Type.tdchar.immutableOf().arrayOf();
             e.committed = 1;
@@ -3020,7 +3027,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             buffer.writeUTF16(0);
             e.setData(buffer.extractData(), newlen, 2);
             if (sc && sc.flags & SCOPE.Cfile)
-                e.type = Type.tuns16.pointerTo();
+                e.type = Type.tuns16.sarrayOf(e.len + 1);
             else
                 e.type = Type.twchar.immutableOf().arrayOf();
             e.committed = 1;
@@ -3032,7 +3039,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
 
         default:
             if (sc && sc.flags & SCOPE.Cfile)
-                e.type = Type.tchar.pointerTo();
+                e.type = Type.tchar.sarrayOf(e.len + 1);
             else
                 e.type = Type.tchar.immutableOf().arrayOf();
             break;
@@ -3170,11 +3177,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
 
         semanticTypeInfo(sc, e.type);
 
-        if (global.params.useDIP1000 == FeatureState.enabled)
-        {
-            if (checkAssocArrayLiteralEscape(sc, e, false))
-                return setError();
-        }
+        if (checkAssocArrayLiteralEscape(sc, e, false))
+            return setError();
 
         result = e;
     }
@@ -3261,7 +3265,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             // to fix https://issues.dlang.org/show_bug.cgi?id=9490
             VarExp ve = e.isVarExp();
             if (ve && ve.var && exp.parens && !ve.var.isStatic() && !(sc.stc & STC.static_) &&
-                sc.func && sc.func.needThis && ve.var.toParent2().isAggregateDeclaration())
+                sc.func && sc.func.needThis && ve.var.isMember2())
             {
                 // printf("apply fix for issue 9490: add `this.` to `%s`...\n", e.toChars());
                 e = new DotVarExp(exp.loc, new ThisExp(exp.loc), ve.var, false);
@@ -3782,13 +3786,10 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
 
                 /* Since a `new` allocation may escape, check each of the arguments for escaping
                  */
-                if (global.params.useDIP1000 == FeatureState.enabled)
+                foreach (arg; *exp.arguments)
                 {
-                    foreach (arg; *exp.arguments)
-                    {
-                        if (arg && checkNewEscape(sc, arg, false))
-                            return setError();
-                    }
+                    if (arg && checkNewEscape(sc, arg, false))
+                        return setError();
                 }
             }
 
@@ -4677,7 +4678,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             }
             if (exp.f.needThis())
             {
-                AggregateDeclaration ad = exp.f.toParentLocal().isAggregateDeclaration();
+                AggregateDeclaration ad = exp.f.isMemberLocal();
                 ue.e1 = getRightThis(exp.loc, sc, ad, ue.e1, exp.f);
                 if (ue.e1.op == EXP.error)
                 {
@@ -4688,7 +4689,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
                 tthis = ue.e1.type;
                 if (!(exp.f.type.ty == Tfunction && (cast(TypeFunction)exp.f.type).isScopeQual))
                 {
-                    if (global.params.useDIP1000 == FeatureState.enabled && checkParamArgumentEscape(sc, exp.f, null, ethis, false, false))
+                    if (checkParamArgumentEscape(sc, exp.f, null, STC.undefined_, ethis, false, false))
                         return setError();
                 }
             }
@@ -5393,7 +5394,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
         {
             if (tb.toDsymbol(sc).isClassDeclaration().classKind == ClassKind.cpp)
             {
-                error(exp.loc, "Runtime type information is not supported for `extern(C++)` classes");
+                error(exp.loc, "runtime type information is not supported for `extern(C++)` classes");
                 e = ErrorExp.get();
             }
             else if (!Type.typeinfoclass)
@@ -6026,18 +6027,18 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             const slice = se.peekString();
             message("file      %.*s\t(%s)", cast(int)slice.length, slice.ptr, name);
         }
-        if (global.params.moduleDeps !is null)
+        if (global.params.moduleDeps.buffer !is null)
         {
-            OutBuffer* ob = global.params.moduleDeps;
+            OutBuffer* ob = global.params.moduleDeps.buffer;
             Module imod = sc._module;
 
-            if (!global.params.moduleDepsFile)
+            if (!global.params.moduleDeps.name)
                 ob.writestring("depsFile ");
             ob.writestring(imod.toPrettyChars());
             ob.writestring(" (");
             escapePath(ob, imod.srcfile.toChars());
             ob.writestring(") : ");
-            if (global.params.moduleDepsFile)
+            if (global.params.moduleDeps.name)
                 ob.writestring("string : ");
             ob.write(se.peekString());
             ob.writestring(" (");
@@ -6045,9 +6046,9 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             ob.writestring(")");
             ob.writenl();
         }
-        if (global.params.emitMakeDeps)
+        if (global.params.makeDeps.doOutput)
         {
-            global.params.makeDeps.push(name);
+            global.params.makeDeps.files.push(name);
         }
 
         {
@@ -6349,7 +6350,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             exp.msg = resolveProperties(sc, exp.msg);
             exp.msg = exp.msg.implicitCastTo(sc, Type.tchar.constOf().arrayOf());
             exp.msg = exp.msg.optimize(WANTvalue);
-            checkParamArgumentEscape(sc, null, null, exp.msg, true, false);
+            checkParamArgumentEscape(sc, null, null, STC.undefined_, exp.msg, true, false);
         }
 
         if (exp.msg && exp.msg.op == EXP.error)
@@ -6625,6 +6626,14 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
 
             exp.type = exp.type.addMod(t1.mod);
 
+            // https://issues.dlang.org/show_bug.cgi?id=23109
+            // Run semantic on the DotVarExp type
+            if (auto handle = exp.type.isClassHandle())
+            {
+                if (handle.semanticRun < PASS.semanticdone && !handle.isBaseInfoComplete())
+                    handle.dsymbolSemantic(null);
+            }
+
             Dsymbol vparent = exp.var.toParent();
             AggregateDeclaration ad = vparent ? vparent.isAggregateDeclaration() : null;
             if (Expression e1x = getRightThis(exp.loc, sc, ad, exp.e1, exp.var, 1))
@@ -6705,24 +6714,12 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
         e.type = e.type.typeSemantic(e.loc, sc);
 
         FuncDeclaration f = e.func.toAliasFunc();
-        AggregateDeclaration ad = f.toParentLocal().isAggregateDeclaration();
+        AggregateDeclaration ad = f.isMemberLocal();
         if (f.needThis())
             e.e1 = getRightThis(e.loc, sc, ad, e.e1, f);
         if (e.e1.op == EXP.error)
             return setError();
 
-        /* A delegate takes the address of e.e1 in order to set the .ptr field
-         * https://issues.dlang.org/show_bug.cgi?id=18575
-         */
-        if (global.params.useDIP1000 == FeatureState.enabled && e.e1.type.toBasetype().ty == Tstruct)
-        {
-            if (auto v = expToVariable(e.e1))
-            {
-                if (!checkAddressVar(sc, e.e1, v))
-                    return setError();
-            }
-        }
-
         if (f.type.ty == Tfunction)
         {
             TypeFunction tf = cast(TypeFunction)f.type;
@@ -6809,20 +6806,26 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
 
         if (sc.flags & SCOPE.Cfile)
         {
-            /* Special handling for &"string"
-             * since C regards a string literal as an lvalue
+            /* Special handling for &"string"/&(T[]){0, 1}
+             * since C regards string/array literals as lvalues
              */
-            if (auto se = exp.e1.isStringExp())
+            auto e = exp.e1;
+            if(e.isStringExp() || e.isArrayLiteralExp())
             {
-                if (auto tp = se.type.toBasetype().isTypePointer())
+                e.type = typeSemantic(e.type, Loc.initial, sc);
+                // if type is already a pointer exp is an illegal expression of the form `&(&"")`
+                if (!e.type.isTypePointer())
                 {
-                    /* Switch from pointer-to-char to pointer-to-static-array-of-char
-                     */
-                    auto ts = new TypeSArray(tp.nextOf(), new IntegerExp(Loc.initial, se.len + 1, Type.tsize_t));
-                    se.type = typeSemantic(ts, Loc.initial, sc).pointerTo();
-                    result = se;
+                    e.type = e.type.pointerTo();
+                    result = e;
                     return;
                 }
+                else
+                {
+                    // `toLvalue` call further below is upon exp.e1, omitting & from the error message
+                    exp.toLvalue(sc, null);
+                    return setError();
+                }
             }
         }
 
@@ -6891,19 +6894,19 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
                          * because it might end up being a pointer to undefined
                          * memory.
                          */
-                        if (sc.func && !sc.intypeof && !(sc.flags & SCOPE.debug_) && sc.func.setUnsafe())
+                        if (sc.func && !sc.intypeof && !(sc.flags & SCOPE.debug_))
                         {
-                            exp.error("cannot take address of lazy parameter `%s` in `@safe` function `%s`",
-                                     ve.toChars(), sc.func.toChars());
-                            setError();
-                        }
-                        else
-                        {
-                            VarExp ve2 = callExp.e1.isVarExp();
-                            ve2.delegateWasExtracted = true;
-                            ve2.var.storage_class |= STC.scope_;
-                            result = ve2;
+                            if (sc.func.setUnsafe(false, exp.loc,
+                                "cannot take address of lazy parameter `%s` in `@safe` function `%s`", ve, sc.func))
+                            {
+                                setError();
+                                return;
+                            }
                         }
+                        VarExp ve2 = callExp.e1.isVarExp();
+                        ve2.delegateWasExtracted = true;
+                        ve2.var.storage_class |= STC.scope_;
+                        result = ve2;
                         return;
                     }
                 }
@@ -6987,15 +6990,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             // Look for misaligned pointer in @safe mode
             if (checkUnsafeAccess(sc, dve, !exp.type.isMutable(), true))
                 return setError();
-
-            if (global.params.useDIP1000 == FeatureState.enabled)
-            {
-                if (VarDeclaration v = expToVariable(dve.e1))
-                {
-                    if (!checkAddressVar(sc, exp.e1, v))
-                        return setError();
-                }
-            }
         }
         else if (exp.e1.op == EXP.variable)
         {
@@ -7049,29 +7043,15 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
                         result = e;
                         return;
                     }
-                    if (sc.func && !sc.intypeof)
+                    if (sc.func && !sc.intypeof && !(sc.flags & SCOPE.debug_))
                     {
-                        if (!(sc.flags & SCOPE.debug_) && sc.func.setUnsafe())
-                        {
-                            exp.error("`this` reference necessary to take address of member `%s` in `@safe` function `%s`", f.toChars(), sc.func.toChars());
-                        }
+                        sc.func.setUnsafe(false, exp.loc,
+                            "`this` reference necessary to take address of member `%s` in `@safe` function `%s`",
+                            f, sc.func);
                     }
                 }
             }
         }
-        else if ((exp.e1.op == EXP.this_ || exp.e1.op == EXP.super_) && global.params.useDIP1000 == FeatureState.enabled)
-        {
-            if (VarDeclaration v = expToVariable(exp.e1))
-            {
-                if (!checkAddressVar(sc, exp.e1, v))
-                    return setError();
-            }
-        }
-        else if (auto ce = exp.e1.isCallExp())
-        {
-            if (!checkAddressCall(sc, ce, "take address of"))
-                return setError();
-        }
         else if (exp.e1.op == EXP.index)
         {
             /* For:
@@ -7081,9 +7061,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
              */
             if (VarDeclaration v = expToVariable(exp.e1))
             {
-                if (global.params.useDIP1000 == FeatureState.enabled && !checkAddressVar(sc, exp.e1, v))
-                    return setError();
-
                 exp.e1.checkPurity(sc, v);
             }
         }
@@ -7839,10 +7816,10 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
 
                 return setError();
             }
-            if (sc.func && !sc.intypeof && !(sc.flags & SCOPE.debug_) && sc.func.setUnsafe())
+            if (sc.func && !sc.intypeof && !(sc.flags & SCOPE.debug_))
             {
-                exp.error("pointer slicing not allowed in safe functions");
-                return setError();
+                if (sc.func.setUnsafe(false, exp.loc, "pointer slicing not allowed in safe functions"))
+                    return setError();
             }
         }
         else if (t1b.ty == Tarray)
@@ -7850,34 +7827,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
         }
         else if (t1b.ty == Tsarray)
         {
-            if (!exp.arrayop && global.params.useDIP1000 == FeatureState.enabled)
-            {
-                /* Slicing a static array is like taking the address of it.
-                 * Perform checks as if e[] was &e
-                 */
-                if (VarDeclaration v = expToVariable(exp.e1))
-                {
-                    if (DotVarExp dve = exp.e1.isDotVarExp())
-                    {
-
-                        if ((dve.e1.op == EXP.this_ || dve.e1.op == EXP.super_) &&
-                            !(v.storage_class & STC.ref_))
-                        {
-                            // because it's a class
-                            v = null;
-                        }
-                    }
-
-                    if (v && !checkAddressVar(sc, exp.e1, v))
-                        return setError();
-                }
-                // https://issues.dlang.org/show_bug.cgi?id=22539
-                if (auto ce = exp.e1.isCallExp())
-                {
-                    if (!checkAddressCall(sc, ce, "slice static array of"))
-                        return setError();
-                }
-            }
         }
         else if (t1b.ty == Ttuple)
         {
@@ -8202,7 +8151,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             discardValue(e.e1);
         }
         else if (!e.allowCommaExp && !e.isGenerated)
-            e.error("Using the result of a comma expression is not allowed");
+            e.error("using the result of a comma expression is not allowed");
     }
 
     override void visit(IntervalExp e)
@@ -8379,10 +8328,11 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             if (exp.e2.op == EXP.int64 && exp.e2.toInteger() == 0)
             {
             }
-            else if (sc.func && !(sc.flags & SCOPE.debug_) && sc.func.setUnsafe())
+            else if (sc.func && !(sc.flags & SCOPE.debug_))
             {
-                exp.error("safe function `%s` cannot index pointer `%s`", sc.func.toPrettyChars(), exp.e1.toChars());
-                return setError();
+                if (sc.func.setUnsafe(false, exp.loc,
+                    "`@safe` function `%s` cannot index pointer `%s`", sc.func, exp.e1))
+                    return setError();
             }
             exp.type = (cast(TypeNext)t1b).next;
             break;
@@ -8675,10 +8625,10 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
     {
         static if (LOGSEMANTIC)
         {
-            printf("AssignExp::semantic('%s')\n", exp.toChars());
+            if (exp.op == EXP.blit)      printf("BlitExp.toElem('%s')\n", exp.toChars());
+            if (exp.op == EXP.assign)    printf("AssignExp.toElem('%s')\n", exp.toChars());
+            if (exp.op == EXP.construct) printf("ConstructExp.toElem('%s')\n", exp.toChars());
         }
-        //printf("exp.e1.op = %d, '%s'\n", exp.e1.op, EXPtoString(exp.e1.op).ptr);
-        //printf("exp.e2.op = %d, '%s'\n", exp.e2.op, EXPtoString(exp.e2.op).ptr);
 
         void setResult(Expression e, int line = __LINE__)
         {
@@ -8696,7 +8646,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
         if (auto e2comma = exp.e2.isCommaExp())
         {
             if (!e2comma.isGenerated && !(sc.flags & SCOPE.Cfile))
-                exp.error("Using the result of a comma expression is not allowed");
+                exp.error("using the result of a comma expression is not allowed");
 
             /* Rewrite to get rid of the comma from rvalue
              *   e1=(e0,e2) => e0,(e1=e2)
@@ -9425,6 +9375,23 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             Expression e1x = exp.e1;
             Expression e2x = exp.e2;
 
+            /* C strings come through as static arrays. May need to adjust the size of the
+             * string to match the size of e1.
+             */
+            Type t2 = e2x.type.toBasetype();
+            if (sc.flags & SCOPE.Cfile && e2x.isStringExp() && t2.isTypeSArray())
+            {
+                uinteger_t dim1 = t1.isTypeSArray().dim.toInteger();
+                uinteger_t dim2 = t2.isTypeSArray().dim.toInteger();
+                if (dim1 + 1 == dim2 || dim2 < dim1)
+                {
+                    auto tsa2 = t2.isTypeSArray();
+                    auto newt = tsa2.next.sarrayOf(dim1).immutableOf();
+                    e2x = castTo(e2x, sc, newt);
+                    exp.e2 = e2x;
+                }
+            }
+
             if (e2x.implicitConvTo(e1x.type))
             {
                 if (exp.op != EXP.blit && (e2x.op == EXP.slice && (cast(UnaExp)e2x).e1.isLvalue() || e2x.op == EXP.cast_ && (cast(UnaExp)e2x).e1.isLvalue() || e2x.op != EXP.slice && e2x.isLvalue()))
@@ -9686,13 +9653,14 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
                 tsa2 = cast(TypeSArray)toStaticArrayType(se);
             else
                 tsa2 = t2.isTypeSArray();
+
             if (tsa1 && tsa2)
             {
                 uinteger_t dim1 = tsa1.dim.toInteger();
                 uinteger_t dim2 = tsa2.dim.toInteger();
                 if (dim1 != dim2)
                 {
-                    exp.error("mismatched array lengths, %d and %d", cast(int)dim1, cast(int)dim2);
+                    exp.error("mismatched array lengths %d and %d for assignment `%s`", cast(int)dim1, cast(int)dim2, exp.toChars());
                     return setError();
                 }
             }
@@ -9761,10 +9729,10 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             }
             if (t1n.toBasetype.ty == Tvoid && t2n.toBasetype.ty == Tvoid)
             {
-                if (!sc.intypeof && sc.func && !(sc.flags & SCOPE.debug_) && sc.func.setUnsafe())
+                if (!sc.intypeof && sc.func && !(sc.flags & SCOPE.debug_))
                 {
-                    exp.error("cannot copy `void[]` to `void[]` in `@safe` code");
-                    return setError();
+                    if (sc.func.setUnsafe(false, exp.loc, "cannot copy `void[]` to `void[]` in `@safe` code"))
+                        return setError();
                 }
             }
         }
@@ -10190,10 +10158,135 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
 
         exp.type = exp.e1.type;
         auto res = exp.reorderSettingAAElem(sc);
-        if ((exp.op == EXP.concatenateElemAssign || exp.op == EXP.concatenateDcharAssign) &&
-            global.params.useDIP1000 == FeatureState.enabled)
+        if (exp.op == EXP.concatenateElemAssign || exp.op == EXP.concatenateDcharAssign)
             checkAssignEscape(sc, res, false, false);
         result = res;
+
+        if ((exp.op == EXP.concatenateAssign || exp.op == EXP.concatenateElemAssign) &&
+            !(sc.flags & (SCOPE.ctfe | SCOPE.compile)))
+        {
+            // if aa ordering is triggered, `res` will be a CommaExp
+            // and `.e2` will be the rewritten original expression.
+
+            // `output` will point to the expression that the lowering will overwrite
+            Expression* output;
+            if (auto comma = res.isCommaExp())
+            {
+                output = &comma.e2;
+                // manual cast because it could be either CatAssignExp or CatElemAssignExp
+                exp = cast(CatAssignExp)comma.e2;
+            }
+            else
+            {
+                output = &result;
+                exp = cast(CatAssignExp)result;
+            }
+
+            if (exp.op == EXP.concatenateAssign)
+            {
+                Identifier hook = global.params.tracegc ? Id._d_arrayappendTTrace : Id._d_arrayappendT;
+
+                if (!verifyHookExist(exp.loc, *sc, hook, "appending array to arrays", Id.object))
+                    return setError();
+
+                // Lower to object._d_arrayappendT{,Trace}({file, line, funcname}, e1, e2)
+                Expression id = new IdentifierExp(exp.loc, Id.empty);
+                id = new DotIdExp(exp.loc, id, Id.object);
+                id = new DotIdExp(exp.loc, id, hook);
+
+                auto arguments = new Expressions();
+                arguments.reserve(5);
+                if (global.params.tracegc)
+                {
+                    auto funcname = (sc.callsc && sc.callsc.func) ? sc.callsc.func.toPrettyChars() : sc.func.toPrettyChars();
+                    arguments.push(new StringExp(exp.loc, exp.loc.filename.toDString()));
+                    arguments.push(new IntegerExp(exp.loc, exp.loc.linnum, Type.tint32));
+                    arguments.push(new StringExp(exp.loc, funcname.toDString()));
+                }
+
+                arguments.push(exp.e1);
+                arguments.push(exp.e2);
+                Expression ce = new CallExp(exp.loc, id, arguments);
+                *output = ce.expressionSemantic(sc);
+            }
+            else if (exp.op == EXP.concatenateElemAssign)
+            {
+                /* Do not lower concats to the indices array returned by
+                 *`static foreach`, as this array is only used at compile-time.
+                 */
+                if (auto ve = exp.e1.isVarExp)
+                {
+                    import core.stdc.ctype : isdigit;
+                    // The name of the indices array that static foreach loops uses.
+                    // See dmd.cond.lowerNonArrayAggregate
+                    enum varName = "__res";
+                    const(char)[] id = ve.var.ident.toString;
+                    if (ve.var.storage_class & STC.temp && id.length > varName.length &&
+                        id[0 .. varName.length] == varName && id[varName.length].isdigit)
+                        return;
+                }
+
+                Identifier hook = global.params.tracegc ? Id._d_arrayappendcTXTrace : Id._d_arrayappendcTX;
+                if (!verifyHookExist(exp.loc, *sc, Id._d_arrayappendcTXImpl, "appending element to arrays", Id.object))
+                    return setError();
+
+                // Lower to object._d_arrayappendcTXImpl!(typeof(e1))._d_arrayappendcTX{,Trace}(e1, 1), e1[$-1]=e2
+                Expression id = new IdentifierExp(exp.loc, Id.empty);
+                id = new DotIdExp(exp.loc, id, Id.object);
+                auto tiargs = new Objects();
+                tiargs.push(exp.e1.type);
+                id = new DotTemplateInstanceExp(exp.loc, id, Id._d_arrayappendcTXImpl, tiargs);
+                id = new DotIdExp(exp.loc, id, hook);
+
+                auto arguments = new Expressions();
+                arguments.reserve(5);
+                if (global.params.tracegc)
+                {
+                    auto funcname = (sc.callsc && sc.callsc.func) ? sc.callsc.func.toPrettyChars() : sc.func.toPrettyChars();
+                    arguments.push(new StringExp(exp.loc, exp.loc.filename.toDString()));
+                    arguments.push(new IntegerExp(exp.loc, exp.loc.linnum, Type.tint32));
+                    arguments.push(new StringExp(exp.loc, funcname.toDString()));
+                }
+
+                Expression eValue1;
+                Expression value1 = extractSideEffect(sc, "__appendtmp", eValue1, exp.e1);
+
+                arguments.push(value1);
+                arguments.push(new IntegerExp(exp.loc, 1, Type.tsize_t));
+
+                Expression ce = new CallExp(exp.loc, id, arguments);
+
+                Expression eValue2;
+                Expression value2 = exp.e2;
+                if (!value2.isVarExp() && !value2.isConst())
+                {
+                    /* Before the template hook, this check was performed in e2ir.d
+                     * for expressions like `a ~= a[$-1]`. Here, $ will be modified
+                     * by calling `_d_arrayappendcT`, so we need to save `a[$-1]` in
+                     * a temporary variable.
+                     */
+                    value2 = extractSideEffect(sc, "__appendtmp", eValue2, value2, true);
+                    exp.e2 = value2;
+
+                    // `__appendtmp*` will be destroyed together with the array `exp.e1`.
+                    auto vd = eValue2.isDeclarationExp().declaration.isVarDeclaration();
+                    vd.storage_class |= STC.nodtor;
+                }
+
+                auto ale = new ArrayLengthExp(exp.loc, value1);
+                auto elem = new IndexExp(exp.loc, value1, new MinExp(exp.loc, ale, IntegerExp.literal!1));
+                auto ae = new ConstructExp(exp.loc, elem, value2);
+
+                auto e0 = Expression.combine(ce, ae).expressionSemantic(sc);
+                e0 = Expression.combine(e0, value1);
+                e0 = Expression.combine(eValue1, e0);
+
+                e0 = Expression.combine(eValue2, e0);
+
+                *output = e0.expressionSemantic(sc);
+            }
+        }
+
     }
 
     override void visit(AddExp exp)
@@ -11639,7 +11732,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
             auto t1 = exp.e1.type;
             auto t2 = exp.e2.type;
             if (t1.ty == Tenum && t2.ty == Tenum && !t1.equivalent(t2))
-                exp.error("Comparison between different enumeration types `%s` and `%s`; If this behavior is intended consider using `std.conv.asOriginalType`",
+                exp.error("comparison between different enumeration types `%s` and `%s`; If this behavior is intended consider using `std.conv.asOriginalType`",
                     t1.toChars(), t2.toChars());
         }
 
@@ -11996,7 +12089,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
         }
         // C11 6.5.1.1 Generic Selection
 
-        auto ec = exp.cntlExp.expressionSemantic(sc);
+        auto ec = exp.cntlExp.expressionSemantic(sc).arrayFuncConv(sc);
         bool errors = ec.isErrorExp() !is null;
         auto tc = ec.type;
 
@@ -12622,12 +12715,21 @@ Expression semanticY(DotIdExp exp, Scope* sc, int flag)
         Expression e = new IntegerExp(exp.loc, actualAlignment, Type.tsize_t);
         return e;
     }
-    else if (cfile && exp.ident == Id.__sizeof && exp.e1.isStringExp())
+    else if ((exp.ident == Id.max || exp.ident == Id.min) &&
+             exp.e1.isVarExp() &&
+             exp.e1.isVarExp().var.isBitFieldDeclaration())
     {
-        // Sizeof string literal includes the terminating 0
-        auto se = exp.e1.isStringExp();
-        Expression e = new IntegerExp(exp.loc, (se.len + 1) * se.sz, Type.tsize_t);
-        return e;
+        // For `x.max` and `x.min` get the max/min of the bitfield, not the max/min of its type
+        auto bf = exp.e1.isVarExp().var.isBitFieldDeclaration();
+        return new IntegerExp(exp.loc, bf.getMinMax(exp.ident), bf.type);
+    }
+    else if ((exp.ident == Id.max || exp.ident == Id.min) &&
+             exp.e1.isDotVarExp() &&
+             exp.e1.isDotVarExp().var.isBitFieldDeclaration())
+    {
+        // For `x.max` and `x.min` get the max/min of the bitfield, not the max/min of its type
+        auto bf = exp.e1.isDotVarExp().var.isBitFieldDeclaration();
+        return new IntegerExp(exp.loc, bf.getMinMax(exp.ident), bf.type);
     }
     else
     {
@@ -12635,7 +12737,9 @@ Expression semanticY(DotIdExp exp, Scope* sc, int flag)
             flag = 0;
         Expression e = exp.e1.type.dotExp(sc, exp.e1, exp.ident, flag | (exp.noderef ? DotExpFlag.noDeref : 0));
         if (e)
+        {
             e = e.expressionSemantic(sc);
+        }
         return e;
     }
 }
@@ -12982,22 +13086,12 @@ bool checkAddressVar(Scope* sc, Expression exp, VarDeclaration v)
         if (sc.func && !sc.intypeof && !v.isDataseg())
         {
             const(char)* p = v.isParameter() ? "parameter" : "local";
-            if (global.params.useDIP1000 == FeatureState.enabled)
-            {
-                // Taking the address of v means it cannot be set to 'scope' later
-                v.storage_class &= ~STC.maybescope;
-                v.doNotInferScope = true;
-                if (exp.type.hasPointers() && v.storage_class & STC.scope_ &&
-                    !(v.storage_class & STC.temp) &&
-                    !(sc.flags & SCOPE.debug_) && sc.func.setUnsafe())
-                {
-                    exp.error("cannot take address of `scope` %s `%s` in `@safe` function `%s`", p, v.toChars(), sc.func.toChars());
-                    return false;
-                }
-            }
-            else if (!(sc.flags & SCOPE.debug_) &&
-                     !(v.storage_class & STC.temp) &&
-                     sc.func.setUnsafe())
+            v.storage_class &= ~STC.maybescope;
+            v.doNotInferScope = true;
+            if (global.params.useDIP1000 != FeatureState.enabled &&
+                !(sc.flags & SCOPE.debug_) &&
+                !(v.storage_class & STC.temp) &&
+                sc.func.setUnsafe())
             {
                 exp.error("cannot take address of %s `%s` in `@safe` function `%s`", p, v.toChars(), sc.func.toChars());
                 return false;
@@ -13007,37 +13101,6 @@ bool checkAddressVar(Scope* sc, Expression exp, VarDeclaration v)
     return true;
 }
 
-/****************************************************
- * Determine if the address of a `ref return` value of
- * a function call with type `tf` can be taken safely.
- *
- * This is currently stricter than necessary: it can be safe to take the
- * address of a `ref` with pointer type when the pointer isn't `scope`, but
- * that involves inspecting the function arguments and parameter types, which
- * is left as a future enhancement.
- *
- * Params:
- *      sc = context
- *      ce = function call in question
- *      action = for the error message, how the pointer is taken, e.g. "slice static array of"
- * Returns:
- *      `true` if ok, `false` for error
- */
-private bool checkAddressCall(Scope* sc, CallExp ce, const(char)* action)
-{
-    if (auto tf = ce.e1.type.isTypeFunction())
-    {
-        if (tf.isref && sc.func && !sc.intypeof && !(sc.flags & SCOPE.debug_)
-            && tf.next.hasPointers() && sc.func.setUnsafe())
-        {
-            ce.error("cannot %s `ref return` of `%s()` in `@safe` function `%s`",
-                action, ce.e1.toChars(), sc.func.toChars());
-            ce.errorSupplemental("return type `%s` has pointers that may be `scope`", tf.next.toChars());
-            return false;
-        }
-    }
-    return true;
-}
 
 /*******************************
  * Checks the attributes of a function.
@@ -13241,10 +13304,9 @@ private bool fit(StructDeclaration sd, const ref Loc loc, Scope* sc, Expressions
         {
             if ((!stype.alignment.isDefault() && stype.alignment.get() < target.ptrsize ||
                  (v.offset & (target.ptrsize - 1))) &&
-                (sc.func && sc.func.setUnsafe()))
+                (sc.func && sc.func.setUnsafe(false, loc,
+                    "field `%s.%s` cannot assign to misaligned pointers in `@safe` code", sd, v)))
             {
-                .error(loc, "field `%s.%s` cannot assign to misaligned pointers in `@safe` code",
-                       sd.toChars(), v.toChars());
                 return false;
             }
         }
index 8d8395188b63d4ec5f737d3f2bdb817b2d244cbe..e53a540bb128a0299d8f2e0d48996992d3b8792c 100644 (file)
@@ -344,6 +344,10 @@ extern (C++) class FuncDeclaration : Declaration
 
     FuncDeclarations *inlinedNestedCallees;
 
+    /// In case of failed `@safe` inference, store the error that made the function `@system` for
+    /// better diagnostics
+    private AttributeViolation* safetyViolation;
+
     /// Function flags: A collection of boolean packed for memory efficiency
     /// See the `FUNCFLAG` enum
     uint flags = FUNCFLAG.NRVO;
@@ -1207,12 +1211,12 @@ extern (C++) class FuncDeclaration : Declaration
 
     final bool isMain() const
     {
-        return ident == Id.main && linkage != LINK.c && !isMember() && !isNested();
+        return ident == Id.main && resolvedLinkage() != LINK.c && !isMember() && !isNested();
     }
 
     final bool isCMain() const
     {
-        return ident == Id.main && linkage == LINK.c && !isMember() && !isNested();
+        return ident == Id.main && resolvedLinkage() == LINK.c && !isMember() && !isNested();
     }
 
     final bool isWinMain() const
@@ -1220,24 +1224,24 @@ extern (C++) class FuncDeclaration : Declaration
         //printf("FuncDeclaration::isWinMain() %s\n", toChars());
         version (none)
         {
-            bool x = ident == Id.WinMain && linkage != LINK.c && !isMember();
+            bool x = ident == Id.WinMain && resolvedLinkage() != LINK.c && !isMember();
             printf("%s\n", x ? "yes" : "no");
             return x;
         }
         else
         {
-            return ident == Id.WinMain && linkage != LINK.c && !isMember();
+            return ident == Id.WinMain && resolvedLinkage() != LINK.c && !isMember();
         }
     }
 
     final bool isDllMain() const
     {
-        return ident == Id.DllMain && linkage != LINK.c && !isMember();
+        return ident == Id.DllMain && resolvedLinkage() != LINK.c && !isMember();
     }
 
     final bool isRtInit() const
     {
-        return ident == Id.rt_init && linkage == LINK.c && !isMember() && !isNested();
+        return ident == Id.rt_init && resolvedLinkage() == LINK.c && !isMember() && !isNested();
     }
 
     override final bool isExport() const
@@ -1349,8 +1353,7 @@ extern (C++) class FuncDeclaration : Declaration
             flags |= FUNCFLAG.returnInprocess;
 
         // Initialize for inferring STC.scope_
-        if (global.params.useDIP1000 == FeatureState.enabled)
-            flags |= FUNCFLAG.inferScope;
+        flags |= FUNCFLAG.inferScope;
     }
 
     final PURE isPure()
@@ -1427,24 +1430,51 @@ extern (C++) class FuncDeclaration : Declaration
     }
 
     /**************************************
-     * The function is doing something unsafe,
-     * so mark it as unsafe.
-     * If there's a safe error, return true.
+     * The function is doing something unsafe, so mark it as unsafe.
+     *
+     * Params:
+     *   gag = surpress error message (used in escape.d)
+     *   loc = location of error
+     *   fmt = printf-style format string
+     *   arg0  = (optional) argument for first %s format specifier
+     *   arg1  = (optional) argument for second %s format specifier
+     * Returns: whether there's a safe error
      */
-    extern (D) final bool setUnsafe()
+    extern (D) final bool setUnsafe(
+        bool gag = false, Loc loc = Loc.init, const(char)* fmt = null, RootObject arg0 = null, RootObject arg1 = null)
     {
         if (flags & FUNCFLAG.safetyInprocess)
         {
             flags &= ~FUNCFLAG.safetyInprocess;
             type.toTypeFunction().trust = TRUST.system;
+            if (!gag && !safetyViolation && (fmt || arg0))
+                safetyViolation = new AttributeViolation(loc, fmt, arg0, arg1);
+
             if (fes)
                 fes.func.setUnsafe();
         }
         else if (isSafe())
+        {
+            if (!gag && fmt)
+                .error(loc, fmt, arg0 ? arg0.toChars() : "", arg1 ? arg1.toChars() : "");
+
             return true;
+        }
         return false;
     }
 
+    /**************************************
+     * The function is calling `@system` function `f`, so mark it as unsafe.
+     *
+     * Params:
+     *   f = function being called (needed for diagnostic of inferred functions)
+     * Returns: whether there's a safe error
+     */
+    extern (D) final bool setUnsafeCall(FuncDeclaration f)
+    {
+        return setUnsafe(false, f.loc, null, f, null);
+    }
+
     final bool isNogc()
     {
         //printf("isNogc() %s, inprocess: %d\n", toChars(), !!(flags & FUNCFLAG.nogcInprocess));
@@ -1474,6 +1504,12 @@ extern (C++) class FuncDeclaration : Declaration
         return !!(this.flags & FUNCFLAG.naked);
     }
 
+    final void isNaked(bool v) @safe pure nothrow @nogc
+    {
+        if (v) this.flags |= FUNCFLAG.naked;
+        else this.flags &= ~FUNCFLAG.naked;
+    }
+
     final bool isGenerated() const scope @safe pure nothrow @nogc
     {
         return !!(this.flags & FUNCFLAG.generated);
@@ -1520,11 +1556,23 @@ extern (C++) class FuncDeclaration : Declaration
         return !!(this.flags & FUNCFLAG.CRTCtor);
     }
 
+    final void isCrtCtor(bool v) @safe pure nothrow @nogc
+    {
+        if (v) this.flags |= FUNCFLAG.CRTCtor;
+        else this.flags &= ~FUNCFLAG.CRTCtor;
+    }
+
     final bool isCrtDtor() const scope @safe pure nothrow @nogc
     {
         return !!(this.flags & FUNCFLAG.CRTDtor);
     }
 
+    final void isCrtDtor(bool v) @safe pure nothrow @nogc
+    {
+        if (v) this.flags |= FUNCFLAG.CRTDtor;
+        else this.flags &= ~FUNCFLAG.CRTDtor;
+    }
+
     /**************************************
      * The function is doing something that may allocate with the GC,
      * so mark it as not nogc (not no-how).
@@ -1758,7 +1806,7 @@ extern (C++) class FuncDeclaration : Declaration
         auto f = toAliasFunc();
         //printf("\ttoParent2() = '%s'\n", f.toParent2().toChars());
         return ((f.storage_class & STC.static_) == 0) &&
-                (f.linkage == LINK.d) &&
+                (f._linkage == LINK.d) &&
                 (f.toParent2().isFuncDeclaration() !is null ||
                  f.toParent2() !is f.toParentLocal());
     }
@@ -2645,7 +2693,7 @@ extern (C++) class FuncDeclaration : Declaration
             tf = new TypeFunction(ParameterList(fparams), treturn, LINK.c, stc);
             fd = new FuncDeclaration(Loc.initial, Loc.initial, id, STC.static_, tf);
             fd.visibility = Visibility(Visibility.Kind.public_);
-            fd.linkage = LINK.c;
+            fd._linkage = LINK.c;
 
             st.insert(fd);
         }
@@ -2705,6 +2753,7 @@ extern (C++) class FuncDeclaration : Declaration
         const nparams = tf.parameterList.length;
         bool argerr;
 
+        const linkage = resolvedLinkage();
         if (linkage == LINK.d)
         {
             if (nparams == 1)
@@ -4271,3 +4320,47 @@ extern (C++) final class NewDeclaration : FuncDeclaration
         v.visit(this);
     }
 }
+
+/// Stores a reason why a function failed to infer a function attribute like `@safe` or `pure`
+///
+/// Has two modes:
+/// - a regular safety error, stored in (fmtStr, arg0, arg1)
+/// - a call to a function without the attribute, which is a special case, because in that case,
+///   that function might recursively also have a `AttributeViolation`. This way, in case
+///   of a big call stack, the error can go down all the way to the root cause.
+///   The `FunctionDeclaration` is then stored in `arg0` and `fmtStr` must be `null`.
+private struct AttributeViolation
+{
+    /// location of error
+    Loc loc = Loc.init;
+    /// printf-style format string
+    const(char)* fmtStr = null;
+    /// Arguments for up to two `%s` format specifiers in format string
+    RootObject arg0 = null;
+    /// ditto
+    RootObject arg1 = null;
+}
+
+/// Print the reason why `fd` was inferred `@system` as a supplemental error
+/// Params:
+///   fd = function to check
+///   maxDepth = up to how many functions deep to report errors
+void errorSupplementalInferredSafety(FuncDeclaration fd, int maxDepth)
+{
+    if (auto s = fd.safetyViolation)
+    {
+        if (s.fmtStr)
+        {
+            errorSupplemental(s.loc, "which was inferred `@system` because of:");
+            errorSupplemental(s.loc, s.fmtStr, s.arg0 ? s.arg0.toChars() : "", s.arg1 ? s.arg1.toChars() : "");
+        }
+        else if (FuncDeclaration fd2 = cast(FuncDeclaration) s.arg0)
+        {
+            if (maxDepth > 0)
+            {
+                errorSupplemental(s.loc, "which calls `%s`", fd2.toPrettyChars());
+                errorSupplementalInferredSafety(fd2, maxDepth - 1);
+            }
+        }
+    }
+}
index 6b6655c2ea226b6e6381466a8471ad1a9f758cb2..ba4ccbe5134a2bc081da6d50e27fc59c084d77be 100644 (file)
@@ -51,14 +51,6 @@ enum CHECKACTION : ubyte
     context,      /// call D assert with the error context on failure
 }
 
-/// Position Indepent Code setting
-enum PIC : ubyte
-{
-    fixed,              /// located at a specific address
-    pic,                /// Position Independent Code
-    pie,                /// Position Independent Executable
-}
-
 /**
 Each flag represents a field that can be included in the JSON output.
 
@@ -83,14 +75,6 @@ enum CppStdRevision : uint
     cpp20 = 2020_02,
 }
 
-/// Configuration for the C++ header generator
-enum CxxHeaderMode : uint
-{
-    none,   /// Don't generate headers
-    silent, /// Generate headers
-    verbose /// Generate headers and add comments for hidden declarations
-}
-
 /// Trivalent boolean to represent the state of a `revert`able change
 enum FeatureState : byte
 {
@@ -99,15 +83,24 @@ enum FeatureState : byte
     enabled = 1    /// Specified as `-preview=`
 }
 
+extern(C++) struct Output
+{
+    bool doOutput;      // Output is enabled
+    bool fullOutput;    // Generate comments for hidden declarations (for -HC),
+                        // and don't strip the bodies of plain (non-template) functions (for -H)
+
+    const(char)[] dir;  // write to directory 'dir'
+    const(char)[] name; // write to file 'name'
+    Array!(const(char)*) files; // Other files associated with this output,
+                                // e.g. macro include files for Ddoc, dependencies for makedeps
+    OutBuffer* buffer;  // if this output is buffered, this is the buffer
+    int bufferLines;    // number of lines written to the buffer
+}
 /// Put command line switches in here
 extern (C++) struct Param
 {
     bool obj = true;        // write object file
-    bool link = true;       // perform link
-    bool dll;               // generate shared dynamic library
-    bool lib;               // write library file instead of object file(s)
     bool multiobj;          // break one object file into multiple ones
-    bool oneobj;            // write one object file instead of multiple ones
     bool trace;             // insert profiling hooks
     bool tracegc;           // instrument calls to 'new'
     bool verbose;           // verbose compile
@@ -120,11 +113,7 @@ extern (C++) struct Param
     bool vfield;            // identify non-mutable field variables
     bool vcomplex = true;   // identify complex/imaginary type usage
     bool vin;               // identify 'in' parameters
-    ubyte symdebug;         // insert debug symbolic information
-    bool symdebugref;       // insert debug information for all referenced types, too
-    bool optimize;          // run optimizer
     DiagnosticReporting useDeprecated = DiagnosticReporting.inform;  // how use of deprecated features are handled
-    bool stackstomp;            // add stack stomping code
     bool useUnitTests;          // generate unittest code
     bool useInline = false;     // inline expand functions
     FeatureState useDIP25;  // implement https://wiki.dlang.org/DIP25
@@ -133,12 +122,10 @@ extern (C++) struct Param
     bool release;           // build release version
     bool preservePaths;     // true means don't strip path from source file
     DiagnosticReporting warnings = DiagnosticReporting.off;  // how compiler warnings are handled
-    PIC pic = PIC.fixed;    // generate fixed, pic or pie code
     bool color;             // use ANSI colors in console output
     bool cov;               // generate code coverage data
     ubyte covPercent;       // 0..100 code coverage percentage required
     bool ctfe_cov = false;  // generate coverage data for ctfe
-    bool nofloat;           // code should not pull in floating point support
     bool ignoreUnsupportedPragmas;  // rather than error on them
     bool useModuleInfo = true;   // generate runtime module information
     bool useTypeInfo = true;     // generate runtime type information
@@ -162,6 +149,7 @@ extern (C++) struct Param
     FeatureState dtorFields; // destruct fields of partially constructed objects
                             // https://issues.dlang.org/show_bug.cgi?id=14246
     bool fieldwise;         // do struct equality testing field-wise rather than by memcmp()
+    bool bitfields;         // support C style bit fields
     FeatureState rvalueRefParam; // allow rvalues to be arguments to ref parameters
                                  // https://dconf.org/2019/talks/alexandrescu.html
                                  // https://gist.github.com/andralex/e5405a5d773f07f73196c05f8339435a
@@ -170,9 +158,6 @@ extern (C++) struct Param
 
     CppStdRevision cplusplus = CppStdRevision.cpp11;    // version of C++ standard to support
 
-    bool markdown = true;   // enable Markdown replacements in Ddoc
-    bool vmarkdown;         // list instances of Markdown replacements in Ddoc
-
     bool showGaggedErrors;  // print gagged errors anyway
     bool printErrorContext;  // print errors with the error context (the error line in the source file)
     bool manual;            // open browser on compiler manual
@@ -207,27 +192,14 @@ extern (C++) struct Param
     const(char)[] objname;               // .obj file output name
     const(char)[] libname;               // .lib file output name
 
-    bool doDocComments;                 // process embedded documentation comments
-    const(char)[] docdir;               // write documentation file to docdir directory
-    const(char)[] docname;              // write documentation file to docname
-    Array!(const(char)*) ddocfiles;     // macro include files for Ddoc
-
-    bool doHdrGeneration;               // process embedded documentation comments
-    const(char)[] hdrdir;                // write 'header' file to docdir directory
-    const(char)[] hdrname;               // write 'header' file to docname
-    bool hdrStripPlainFunctions = true; // strip the bodies of plain (non-template) functions
-
-    CxxHeaderMode doCxxHdrGeneration;      /// Generate 'Cxx header' file
-    const(char)[] cxxhdrdir;            // write 'header' file to docdir directory
-    const(char)[] cxxhdrname;           // write 'header' file to docname
-
-    bool doJsonGeneration;              // write JSON file
-    const(char)[] jsonfilename;          // write JSON file to jsonfilename
+    Output ddoc;                        // Generate embedded documentation comments
+    Output dihdr;                       // Generate `.di` 'header' files
+    Output cxxhdr;                      // Generate 'Cxx header' file
+    Output json;                        // Generate JSON file
     JsonFieldFlags jsonFieldFlags;      // JSON field flags to include
-
-    OutBuffer* mixinOut;                // write expanded mixins for debugging
-    const(char)* mixinFile;             // .mixin file output name
-    int mixinLines;                     // Number of lines in writeMixins
+    Output makeDeps;                    // Generate make file dependencies
+    Output mixinOut;                    // write expanded mixins for debugging
+    Output moduleDeps;                  // Generate `.deps` module dependencies
 
     uint debuglevel;                    // debug level
     Array!(const(char)*)* debugids;     // debug identifiers
@@ -235,21 +207,12 @@ extern (C++) struct Param
     uint versionlevel;                  // version level
     Array!(const(char)*)* versionids;   // version identifiers
 
-    const(char)[] defaultlibname;        // default library for non-debug builds
-    const(char)[] debuglibname;          // default library for debug builds
-    const(char)[] mscrtlib;              // MS C runtime library
-
-    const(char)[] moduleDepsFile;        // filename for deps output
-    OutBuffer* moduleDeps;              // contents to be written to deps file
-
-    bool emitMakeDeps;                   // whether to emit makedeps
-    const(char)[] makeDepsFile;          // filename for makedeps output
-    Array!(const(char)*) makeDeps;      // dependencies for makedeps
 
     MessageStyle messageStyle = MessageStyle.digitalmars; // style of file/line annotations on messages
 
     bool run; // run resulting executable
     Strings runargs; // arguments for executable
+    Array!(const(char)*) cppswitches;   // C preprocessor switches
 
     // Linker stuff
     Array!(const(char)*) objfiles;
@@ -335,6 +298,8 @@ extern (C++) struct Global
 
     enum recursionLimit = 500; /// number of recursive template expansions before abort
 
+    extern (C++) FileName function(FileName, const(char)* importc_h, ref Array!(const(char)*) cppswitches, out bool) preprocess;
+
   nothrow:
 
     /**
@@ -468,15 +433,6 @@ extern (C++) struct Global
     {
         return _version.ptr;
     }
-
-    /**
-    Returns: the final defaultlibname based on the command-line parameters
-    */
-    extern (D) const(char)[] finalDefaultlibname() const
-    {
-        return params.betterC ? null :
-            params.symdebug ? params.debuglibname : params.defaultlibname;
-    }
 }
 
 // Because int64_t and friends may be any integral type of the
index 2a33692380ebcd9639b156903c3f2d0641b2857f..5c164fd484d63a8da1ef68af7c7727198a264d05 100644 (file)
@@ -73,14 +73,6 @@ enum CppStdRevision
     CppStdRevisionCpp20 = 202002
 };
 
-/// Configuration for the C++ header generator
-enum class CxxHeaderMode
-{
-    none,   /// Don't generate headers
-    silent, /// Generate headers
-    verbose /// Generate headers and add comments for hidden declarations
-};
-
 /// Trivalent boolean to represent the state of a `revert`able change
 enum class FeatureState : signed char
 {
@@ -89,15 +81,25 @@ enum class FeatureState : signed char
     enabled = 1    /// Specified as `-preview=`
 };
 
+struct Output
+{
+    /// Configuration for the compiler generator
+    bool doOutput;      // Output is enabled
+    bool fullOutput;    // Generate comments for hidden declarations (for -HC),
+                        // and don't strip the bodies of plain (non-template) functions (for -H)
+    DString dir;   // write to directory 'dir'
+    DString name;  // write to file 'name'
+    Array<const char*> files; // Other files associated with this output,
+                                // e.g. macro include files for Ddoc, dependencies for makedeps
+    OutBuffer* buffer;  // if this output is buffered, this is the buffer
+    int bufferLines;    // number of lines written to the buffer
+};
+
 // Put command line switches in here
 struct Param
 {
     bool obj;           // write object file
-    bool link;          // perform link
-    bool dll;           // generate shared dynamic library
-    bool lib;           // write library file instead of object file(s)
     bool multiobj;      // break one object file into multiple ones
-    bool oneobj;        // write one object file instead of multiple ones
     bool trace;         // insert profiling hooks
     bool tracegc;       // instrument calls to 'new'
     bool verbose;       // verbose compile
@@ -110,11 +112,7 @@ struct Param
     bool vfield;        // identify non-mutable field variables
     bool vcomplex;      // identify complex/imaginary type usage
     bool vin;           // identify 'in' parameters
-    unsigned char symdebug;  // insert debug symbolic information
-    bool symdebugref;   // insert debug information for all referenced types, too
-    bool optimize;      // run optimizer
     Diagnostic useDeprecated;
-    bool stackstomp;    // add stack stomping code
     bool useUnitTests;  // generate unittest code
     bool useInline;     // inline expand functions
     FeatureState useDIP25;      // implement https://wiki.dlang.org/DIP25
@@ -123,12 +121,10 @@ struct Param
     bool release;       // build release version
     bool preservePaths; // true means don't strip path from source file
     Diagnostic warnings;
-    unsigned char pic;  // generate position-independent-code for shared libs
     bool color;         // use ANSI colors in console output
     bool cov;           // generate code coverage data
     unsigned char covPercent;   // 0..100 code coverage percentage required
     bool ctfe_cov;      // generate coverage data for ctfe
-    bool nofloat;       // code should not pull in floating point support
     bool ignoreUnsupportedPragmas;      // rather than error on them
     bool useModuleInfo; // generate runtime module information
     bool useTypeInfo;   // generate runtime type information
@@ -147,10 +143,9 @@ struct Param
     FeatureState dtorFields;  // destruct fields of partially constructed objects
                               // https://issues.dlang.org/show_bug.cgi?id=14246
     bool fieldwise;         // do struct equality testing field-wise rather than by memcmp()
+    bool bitfields;         // support C style bit fields
     FeatureState rvalueRefParam;    // allow rvalues to be arguments to ref parameters
     CppStdRevision cplusplus;  // version of C++ name mangling to support
-    bool markdown;          // enable Markdown replacements in Ddoc
-    bool vmarkdown;         // list instances of Markdown replacements in Ddoc
     bool showGaggedErrors;  // print gagged errors anyway
     bool printErrorContext;  // print errors with the error context (the error line in the source file)
     bool manual;            // open browser on compiler manual
@@ -185,27 +180,14 @@ struct Param
     DString objname;   // .obj file output name
     DString libname;   // .lib file output name
 
-    bool doDocComments;  // process embedded documentation comments
-    DString docdir;      // write documentation file to docdir directory
-    DString docname;     // write documentation file to docname
-    Array<const char *> ddocfiles;  // macro include files for Ddoc
-
-    bool doHdrGeneration;  // process embedded documentation comments
-    DString hdrdir;        // write 'header' file to docdir directory
-    DString hdrname;       // write 'header' file to docname
-    bool hdrStripPlainFunctions; // strip the bodies of plain (non-template) functions
-
-    CxxHeaderMode doCxxHdrGeneration;  // write 'Cxx header' file
-    DString cxxhdrdir;        // write 'header' file to docdir directory
-    DString cxxhdrname;       // write 'header' file to docname
-
-    bool doJsonGeneration;    // write JSON file
-    DString jsonfilename;     // write JSON file to jsonfilename
+    Output ddoc;              // Generate embedded documentation comments
+    Output dihdr;             // Generate `.di` 'header' files
+    Output cxxhdr;            // Generate 'Cxx header' file
+    Output json;              // Generate JSON file
     unsigned jsonFieldFlags;  // JSON field flags to include
-
-    OutBuffer *mixinOut;                // write expanded mixins for debugging
-    const char *mixinFile;             // .mixin file output name
-    int mixinLines;                     // Number of lines in writeMixins
+    Output makeDeps;          // Generate make file dependencies
+    Output mixinOut;          // write expanded mixins for debugging
+    Output moduleDeps;        // Generate `.deps` module dependencies
 
     unsigned debuglevel;   // debug level
     Array<const char *> *debugids;     // debug identifiers
@@ -213,22 +195,14 @@ struct Param
     unsigned versionlevel; // version level
     Array<const char *> *versionids;   // version identifiers
 
-    DString defaultlibname;     // default library for non-debug builds
-    DString debuglibname;       // default library for debug builds
-    DString mscrtlib;           // MS C runtime library
-
-    DString moduleDepsFile;     // filename for deps output
-    OutBuffer *moduleDeps;      // contents to be written to deps file
-
-    bool emitMakeDeps;                // whether to emit makedeps
-    DString makeDepsFile;             // filename for makedeps output
-    Array<const char *> makeDeps;     // dependencies for makedeps
 
     MessageStyle messageStyle;  // style of file/line annotations on messages
 
     bool run;           // run resulting executable
     Strings runargs;    // arguments for executable
 
+    Array<const char *> cppswitches; // preprocessor switches
+
     // Linker stuff
     Array<const char *> objfiles;
     Array<const char *> linkswitches;
@@ -296,6 +270,8 @@ struct Global
 
     FileManager* fileManager;
 
+    FileName (*preprocess)(FileName, const char*, Array<const char *>& cppswitches, bool&);
+
     /* Start gagging. Return the current number of gagged errors
      */
     unsigned startGagging();
index 69fdf27e1dbd9af39846306a1e49243e57136319..fd35e1cf846fb7704bac9dcc834fa004e3f41039 100644 (file)
@@ -1536,7 +1536,7 @@ public:
                 bodyToBuffer(f);
                 hgs.autoMember--;
             }
-            else if (hgs.tpltMember == 0 && global.params.hdrStripPlainFunctions)
+            else if (hgs.tpltMember == 0 && global.params.dihdr.fullOutput == false)
             {
                 if (!f.fbody)
                 {
@@ -1621,7 +1621,7 @@ public:
 
     void bodyToBuffer(FuncDeclaration f)
     {
-        if (!f.fbody || (hgs.hdrgen && global.params.hdrStripPlainFunctions && !hgs.autoMember && !hgs.tpltMember))
+        if (!f.fbody || (hgs.hdrgen && global.params.dihdr.fullOutput == false && !hgs.autoMember && !hgs.tpltMember))
         {
             if (!f.fbody && (f.fensures || f.frequires))
             {
index 11455afe263770003b194dfd16ad762c79daae58..ab9528a4f00e241c6bc3912085664b7d6183fdd9 100644 (file)
@@ -349,6 +349,11 @@ immutable Msgtable[] msgtable =
     { "_d_arraysetlengthTImpl"},
     { "_d_arraysetlengthT"},
     { "_d_arraysetlengthTTrace"},
+    { "_d_arrayappendT" },
+    { "_d_arrayappendTTrace" },
+    { "_d_arrayappendcTXImpl" },
+    { "_d_arrayappendcTX" },
+    { "_d_arrayappendcTXTrace" },
 
     // varargs implementation
     { "stdc" },
@@ -454,6 +459,7 @@ immutable Msgtable[] msgtable =
     { "getVirtualFunctions" },
     { "getVirtualMethods" },
     { "classInstanceSize" },
+    { "classInstanceAlignment" },
     { "allMembers" },
     { "derivedMembers" },
     { "isSame" },
index c84a9f69ffa4615e779bd4a9e0b5dc24df6977f3..2cddd282a0262bea1da077d74bb8e612dee33233 100644 (file)
@@ -198,14 +198,16 @@ extern(C++) Initializer initializerSemantic(Initializer init, Scope* sc, ref Typ
                 {
                     if ((!t.alignment.isDefault() && t.alignment.get() < target.ptrsize ||
                          (vd.offset & (target.ptrsize - 1))) &&
-                        sc.func && sc.func.setUnsafe())
+                        sc.func)
                     {
-                        error(i.value[j].loc, "field `%s.%s` cannot assign to misaligned pointers in `@safe` code",
-                            sd.toChars(), vd.toChars());
-                        errors = true;
-                        elems[fieldi] = ErrorExp.get(); // for better diagnostics on multiple errors
-                        ++fieldi;
-                        continue;
+                        if (sc.func.setUnsafe(false, i.value[j].loc,
+                            "field `%s.%s` cannot assign to misaligned pointers in `@safe` code", sd, vd))
+                        {
+                            errors = true;
+                            elems[fieldi] = ErrorExp.get(); // for better diagnostics on multiple errors
+                            ++fieldi;
+                            continue;
+                        }
                     }
                 }
 
@@ -502,6 +504,18 @@ extern(C++) Initializer initializerSemantic(Initializer init, Scope* sc, ref Typ
                 i.exp = se.castTo(sc, t);
                 goto L1;
             }
+
+            /* Lop off terminating 0 of initializer for:
+             *  static char s[5] = "hello";
+             */
+            if (sc.flags & SCOPE.Cfile &&
+                typeb.ty == Tsarray &&
+                tynto.isSomeChar &&
+                tb.isTypeSArray().dim.toInteger() + 1 == typeb.isTypeSArray().dim.toInteger())
+            {
+                i.exp = se.castTo(sc, t);
+                goto L1;
+            }
         }
         /* C11 6.7.9-14..15
          * Initialize an array of unknown size with a string.
@@ -573,7 +587,7 @@ extern(C++) Initializer initializerSemantic(Initializer init, Scope* sc, ref Typ
         }
         else if (sc.flags & SCOPE.Cfile && i.exp.isStringExp() &&
             tta && (tta.next.ty == Tint8 || tta.next.ty == Tuns8) &&
-            ti.ty == Tpointer && ti.nextOf().ty == Tchar)
+            ti.ty == Tsarray && ti.nextOf().ty == Tchar)
         {
             /* unsigned char bbb[1] = "";
              *   signed char ccc[1] = "";
index fc270390fa4ac18662696f36eea667828277a09e..a22c664f920cccf7f900d1dbfabd88258e9db00c 100644 (file)
@@ -446,7 +446,7 @@ public:
             return;
         jsonProperties(cast(Dsymbol)d);
         propertyStorageClass("storageClass", d.storage_class);
-        property("linkage", d.linkage);
+        property("linkage", d._linkage);
         property("type", "deco", d.type);
         // Emit originalType if it differs from type
         if (d.type != d.originalType && d.originalType)
@@ -934,7 +934,7 @@ public:
 
         propertyStart("ddocFiles");
         arrayStart();
-        foreach (ddocFile; global.params.ddocfiles)
+        foreach (ddocFile; global.params.ddoc.files)
         {
             item(ddocFile.toDString);
         }
index 13df0d71f3f9ce7ce0f74e26789fa745f72df107..be17ab3e9adc002b9c2bc9f00ac9b48279c77f1a 100644 (file)
@@ -4375,8 +4375,6 @@ extern (C++) final class TypeFunction : TypeNext
     {
         //printf("parameterStorageClass(p: %s)\n", p.toChars());
         auto stc = p.storageClass;
-        if (global.params.useDIP1000 != FeatureState.enabled)
-            return stc;
 
         // When the preview switch is enable, `in` parameters are `scope`
         if (stc & STC.in_ && global.params.previewIn)
@@ -4441,7 +4439,9 @@ extern (C++) final class TypeFunction : TypeNext
         // Check escaping through return value
         Type tret = nextOf().toBasetype();
         if (isref || tret.hasPointers())
+        {
             return stc | STC.scope_ | STC.return_ | STC.returnScope;
+        }
         else
             return stc | STC.scope_;
     }
@@ -4764,12 +4764,31 @@ extern (C++) final class TypeFunction : TypeNext
                                             s ~= "@safe ";
                                         if (!f.isNogc && sc.func.setGC())
                                             s ~= "nogc ";
-                                        s[$-1] = '\0';
-                                        buf.printf("`%s` copy constructor cannot be called from a `%s` context", f.type.toChars(), s.ptr);
-
+                                        if (s)
+                                        {
+                                            s[$-1] = '\0';
+                                            buf.printf("`%s` copy constructor cannot be called from a `%s` context", f.type.toChars(), s.ptr);
+                                        }
+                                        else if (f.isGenerated() && f.isDisabled())
+                                        {
+                                            /* https://issues.dlang.org/show_bug.cgi?id=23097
+                                             * Compiler generated copy constructor failed.
+                                             */
+                                            buf.printf("generating a copy constructor for `struct %s` failed, therefore instances of it are uncopyable",
+                                                       argStruct.toChars());
+                                        }
+                                        else
+                                        {
+                                            /* Although a copy constructor may exist, no suitable match was found.
+                                             * i.e: `inout` constructor creates `const` object, not mutable.
+                                             * Fallback to using the original generic error before bugzilla 22202.
+                                             */
+                                            goto Lnocpctor;
+                                        }
                                     }
                                     else
                                     {
+                                    Lnocpctor:
                                         buf.printf("`struct %s` does not define a copy constructor for `%s` to `%s` copies",
                                                argStruct.toChars(), targ.toChars(), tprm.toChars());
                                     }
@@ -5134,22 +5153,6 @@ extern (C++) final class TypeDelegate : TypeNext
     override Type addStorageClass(StorageClass stc)
     {
         TypeDelegate t = cast(TypeDelegate)Type.addStorageClass(stc);
-        if (global.params.useDIP1000 != FeatureState.enabled)
-            return t;
-
-        /* The rest is meant to add 'scope' to a delegate declaration if it is of the form:
-         *  alias dg_t = void* delegate();
-         *  scope dg_t dg = ...;
-         */
-        if(stc & STC.scope_)
-        {
-            auto n = t.next.addStorageClass(STC.scope_ | STC.scopeinferred);
-            if (n != t.next)
-            {
-                t.next = n;
-                t.deco = t.merge().deco; // mangling supposed to not be changed due to STC.scope_inferrred
-            }
-        }
         return t;
     }
 
@@ -5218,8 +5221,8 @@ extern (C++) final class TypeTraits : Type
     Loc loc;
     /// The expression to resolve as type or symbol.
     TraitsExp exp;
-    /// After `typeSemantic` the symbol when `exp` doesn't represent a type.
-    Dsymbol sym;
+    /// Cached type/symbol after semantic analysis.
+    RootObject obj;
 
     final extern (D) this(const ref Loc loc, TraitsExp exp)
     {
index 6ba47dfa34e9a2f9b2a137166470a5620a5f271c..d2b136443e8fb54c33c11a5c11225abcd42fcb90 100644 (file)
@@ -670,8 +670,8 @@ class TypeTraits : public Type
     Loc loc;
     /// The expression to resolve as type or symbol.
     TraitsExp *exp;
-    /// The symbol when exp doesn't represent a type.
-    Dsymbol *sym;
+    /// Cached type/symbol after semantic analysis.
+    RootObject *obj;
 
     const char *kind();
     TypeTraits *syntaxCopy();
index 2957b3abfab3b73ee11901af3e869aef14aa37da..8cf35851922d6980dae63e40ad77d1cf5edbc642 100644 (file)
@@ -84,6 +84,17 @@ public:
             }
             f.printGCUsage(e.loc, "setting `length` may cause a GC allocation");
         }
+        else if (fd.ident == Id._d_arrayappendT || fd.ident == Id._d_arrayappendcTX)
+        {
+            if (f.setGC())
+            {
+                e.error("cannot use operator `~=` in `@nogc` %s `%s`",
+                    f.kind(), f.toPrettyChars());
+                err = true;
+                return;
+            }
+            f.printGCUsage(e.loc, "operator `~=` may cause a GC allocation");
+        }
     }
 
     override void visit(ArrayLiteralExp e)
@@ -181,14 +192,15 @@ public:
 
     override void visit(CatAssignExp e)
     {
+        /* CatAssignExp will exist in `__traits(compiles, ...)` and in the `.e1` branch of a `__ctfe ? :` CondExp.
+         * The other branch will be `_d_arrayappendcTX(e1, 1), e1[$-1]=e2` which will generate the warning about
+         * GC usage. See visit(CallExp).
+         */
         if (f.setGC())
         {
-            e.error("cannot use operator `~=` in `@nogc` %s `%s`",
-                f.kind(), f.toPrettyChars());
             err = true;
             return;
         }
-        f.printGCUsage(e.loc, "operator `~=` may cause a GC allocation");
     }
 
     override void visit(CatExp e)
index 9e92212ada1bb106c5b62309f65448252b9fe82a..9afedc1c27bff859b0b9168790e59d9d007cb5ee 100644 (file)
@@ -578,7 +578,7 @@ extern(C++) private final class Supported : Objc
 
     override void checkLinkage(FuncDeclaration fd)
     {
-        if (fd.linkage != LINK.objc && fd.objc.selector)
+        if (fd._linkage != LINK.objc && fd.objc.selector)
             fd.error("must have Objective-C linkage to attach a selector");
     }
 
@@ -640,11 +640,11 @@ extern(C++) private final class Supported : Objc
         if (!fd.objc.isOptional)
             return;
 
-        if (fd.linkage != LINK.objc)
+        if (fd._linkage != LINK.objc)
         {
             fd.error("only functions with Objective-C linkage can be declared as optional");
 
-            const linkage = linkageToString(fd.linkage);
+            const linkage = linkageToString(fd._linkage);
 
             errorSupplemental(fd.loc, "function is declared with %.*s linkage",
                 cast(uint) linkage.length, linkage.ptr);
index 3cc36b49e0194cf5f10754f889fe33adcf98cb42..2b7b9ac1013719cb0daa270b8ed6f71ac93aec0d 100644 (file)
@@ -558,6 +558,41 @@ Expression Expression_optimize(Expression e, int result, bool keepLvalue)
         }
         else if (auto ae = e.e1.isIndexExp())
         {
+            if (ae.e2.isIntegerExp() && ae.e1.isIndexExp())
+            {
+                /* Rewrite `(a[i])[index]` to `(&a[i]) + index*size`
+                 */
+                sinteger_t index = ae.e2.toInteger();
+                auto ae1 = ae.e1.isIndexExp();          // ae1 is a[i]
+                if (auto ts = ae1.type.isTypeSArray())
+                {
+                    sinteger_t dim = ts.dim.toInteger();
+
+                    if (index < 0 || index > dim)
+                    {
+                        e.error("array index %lld is out of bounds `[0..%lld]`", index, dim);
+                        return error();
+                    }
+
+                    import core.checkedint : mulu;
+                    bool overflow;
+                    const offset = mulu(index, ts.nextOf().size(e.loc), overflow); // offset = index*size
+                    if (overflow)
+                    {
+                        e.error("array offset overflow");
+                        return error();
+                    }
+
+                    Expression ex = new AddrExp(ae1.loc, ae1);  // &a[i]
+                    ex.type = ae1.type.pointerTo();
+
+                    Expression add = new AddExp(ae.loc, ex, new IntegerExp(ae.loc, offset, e.type));
+                    add.type = e.type;
+                    ret = Expression_optimize(add, result, keepLvalue);
+                    return;
+                }
+            }
+
             // Convert &array[n] to &array+n
             if (ae.e2.isIntegerExp() && ae.e1.isVarExp())
             {
index 4b9c0f2119f5b6e90f7b9b3a1fc89ab2d086c7bf..15b7658a49ad56bf25f863bed9beb5e4426bf546 100644 (file)
@@ -289,6 +289,15 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
         return true;
     }
 
+    /************************************
+     * Parse declarations and definitions
+     * Params:
+     *  once = !=0 means parse exactly one decl or def
+     *  pLastDecl = set to last decl or def parsed
+     *  pAttrs = keep track of attributes
+     * Returns:
+     *  array of declared symbols
+     */
     AST.Dsymbols* parseDeclDefs(int once, AST.Dsymbol* pLastDecl = null, PrefixAttributes!AST* pAttrs = null)
     {
         AST.Dsymbol lastDecl = null; // used to link unittest to its previous declaration
@@ -480,7 +489,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
                  * template instantiations in these unittests as candidates for
                  * further codegen culling.
                  */
-                if (mod.isRoot() && (global.params.useUnitTests || global.params.doDocComments || global.params.doHdrGeneration))
+                if (mod.isRoot() && (global.params.useUnitTests || global.params.ddoc.doOutput || global.params.dihdr.doOutput))
                 {
                     s = parseUnitTest(pAttrs);
                     if (*pLastDecl)
@@ -713,7 +722,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
                     // The deprecation period is longer than usual as `body`
                     // was quite widely used.
                     if (tk.value == TOK.identifier && tk.ident == Id._body)
-                        deprecation("Usage of the `body` keyword is deprecated. Use `do` instead.");
+                        deprecation("usage of the `body` keyword is deprecated. Use `do` instead.");
 
                     a = parseDeclarations(true, pAttrs, pAttrs.comment);
                     if (a && a.dim)
@@ -2649,7 +2658,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
         /** Extract unittest body as a string. Must be done eagerly since memory
          will be released by the lexer before doc gen. */
         char* docline = null;
-        if (global.params.doDocComments && endPtr > begPtr)
+        if (global.params.ddoc.doOutput && endPtr > begPtr)
         {
             /* Remove trailing whitespaces */
             for (const(char)* p = endPtr - 1; begPtr <= p && (*p == ' ' || *p == '\r' || *p == '\n' || *p == '\t'); --p)
@@ -4298,7 +4307,8 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
      * These can be:
      *      1. declarations at global/class level
      *      2. declarations at statement level
-     * Return array of Declaration *'s.
+     * Returns:
+     *  array of Declarations.
      */
     private AST.Dsymbols* parseDeclarations(bool autodecl, PrefixAttributes!AST* pAttrs, const(char)* comment)
     {
@@ -4422,7 +4432,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
                     // The deprecation period is longer than usual as `body`
                     // was quite widely used.
                     if (tk.value == TOK.identifier && tk.ident == Id._body)
-                        deprecation("Usage of the `body` keyword is deprecated. Use `do` instead.");
+                        deprecation("usage of the `body` keyword is deprecated. Use `do` instead.");
 
                     ts = null;
                 }
@@ -4459,6 +4469,12 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
             else if (t != tfirst)
                 error("multiple declarations must have the same type, not `%s` and `%s`", tfirst.toChars(), t.toChars());
 
+            if (token.value == TOK.colon && !ident && t.ty != Tfunction)
+            {
+                // Unnamed bit field
+                ident = Identifier.generateAnonymousId("BitField");
+            }
+
             bool isThis = (t.ty == Tident && (cast(AST.TypeIdentifier)t).ident == Id.This && token.value == TOK.assign);
             if (ident)
                 checkCstyleTypeSyntax(loc, t, alt, ident);
@@ -4591,6 +4607,13 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
             }
             else if (ident)
             {
+                AST.Expression width;
+                if (token.value == TOK.colon)
+                {
+                    nextToken();
+                    width = parseCondExp();
+                }
+
                 AST.Initializer _init = null;
                 if (token.value == TOK.assign)
                 {
@@ -4598,12 +4621,25 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
                     _init = parseInitializer();
                 }
 
-                auto v = new AST.VarDeclaration(loc, t, ident, _init);
-                v.storage_class = storage_class;
-                if (pAttrs)
-                    pAttrs.storageClass = STC.undefined_;
-
-                AST.Dsymbol s = v;
+                AST.Dsymbol s;
+                if (width)
+                {
+                    if (!global.params.bitfields)
+                        error("use -preview=bitfields for bitfield support");
+                    if (_init)
+                        error("initializer not allowed for bit-field declaration");
+                    if (storage_class)
+                        error("storage class not allowed for bit-field declaration");
+                    s = new AST.BitFieldDeclaration(width.loc, t, ident, width);
+                }
+                else
+                {
+                    auto v = new AST.VarDeclaration(loc, t, ident, _init);
+                    v.storage_class = storage_class;
+                    if (pAttrs)
+                        pAttrs.storageClass = STC.undefined_;
+                    s = v;
+                }
 
                 if (tpl && _init)
                 {
@@ -4616,7 +4652,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
                 {
                     auto ax = new AST.Dsymbols();
                     ax.push(s);
-                    s = new AST.AlignDeclaration(v.loc, ealign, ax);
+                    s = new AST.AlignDeclaration(s.loc, ealign, ax);
                 }
                 if (link != linkage)
                 {
@@ -4646,12 +4682,12 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
                 default:
                     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());
+                        error("semicolon needed to end declaration of `%s`, instead of `%s`", s.toChars(), token.toChars());
+                        errorSupplemental(loc, "`%s` declared here", s.toChars());
                     }
                     else
                     {
-                        error("semicolon needed to end declaration of `%s` instead of `%s`", v.toChars(), token.toChars());
+                        error("semicolon needed to end declaration of `%s` instead of `%s`", s.toChars(), token.toChars());
                     }
                     break;
                 }
@@ -4826,7 +4862,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
                     if (udas !is null)
                     {
                         if (storage_class != 0)
-                            error("Cannot put a storage-class in an alias declaration.");
+                            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;
@@ -5034,7 +5070,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
             check(TOK.goesTo);
             if (token.value == TOK.leftCurly)
             {
-                deprecation("Using `(args) => { ... }` to create a delegate that returns a delegate is error-prone.");
+                deprecation("using `(args) => { ... }` to create a delegate that returns a delegate is error-prone.");
                 deprecationSupplemental(token.loc, "Use `(args) { ... }` for a multi-statement function literal or use `(args) => () { }` if you intended for the lambda to return a delegate.");
             }
             const returnloc = token.loc;
@@ -5100,7 +5136,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
                 // Deprecated in 2.097 - Can be removed from 2.117
                 // The deprecation period is longer than usual as `body`
                 // was quite widely used.
-                deprecation("Usage of the `body` keyword is deprecated. Use `do` instead.");
+                deprecation("usage of the `body` keyword is deprecated. Use `do` instead.");
                 goto case TOK.do_;
             }
             goto default;
@@ -7426,7 +7462,7 @@ LagainStc:
                     // Deprecated in 2.097 - Can be removed from 2.117
                     // The deprecation period is longer than usual as `body`
                     // was quite widely used.
-                    deprecation("Usage of the `body` keyword is deprecated. Use `do` instead.");
+                    deprecation("usage of the `body` keyword is deprecated. Use `do` instead.");
                     goto case TOK.do_;
                 }
                 goto default;
@@ -8026,7 +8062,7 @@ LagainStc:
                             postfix = token.postfix;
                         }
 
-                        error("Implicit string concatenation is error-prone and disallowed in D");
+                        error("implicit string concatenation is error-prone and disallowed in D");
                         errorSupplemental(token.loc, "Use the explicit syntax instead " ~
                              "(concatenating literals is `@nogc`): %s ~ %s",
                              prev.toChars(), token.toChars());
@@ -9580,18 +9616,18 @@ private StorageClass getStorageClass(AST)(PrefixAttributes!(AST)* pAttrs)
  */
 private bool writeMixin(const(char)[] s, ref Loc loc)
 {
-    if (!global.params.mixinOut)
+    if (!global.params.mixinOut.doOutput)
         return false;
 
-    OutBuffer* ob = global.params.mixinOut;
+    OutBuffer* ob = global.params.mixinOut.buffer;
 
     ob.writestring("// expansion at ");
     ob.writestring(loc.toChars());
     ob.writenl();
 
-    global.params.mixinLines++;
+    global.params.mixinOut.bufferLines++;
 
-    loc = Loc(global.params.mixinFile, global.params.mixinLines + 1, loc.charnum);
+    loc = Loc(global.params.mixinOut.name.ptr, global.params.mixinOut.bufferLines + 1, loc.charnum);
 
     // write by line to create consistent line endings
     size_t lastpos = 0;
@@ -9603,7 +9639,7 @@ private bool writeMixin(const(char)[] s, ref Loc loc)
         {
             ob.writestring(s[lastpos .. i]);
             ob.writenl();
-            global.params.mixinLines++;
+            global.params.mixinOut.bufferLines++;
             if (c == '\r')
                 ++i;
             lastpos = i + 1;
@@ -9616,10 +9652,10 @@ private bool writeMixin(const(char)[] s, ref Loc loc)
     if (s.length == 0 || s[$-1] != '\n')
     {
         ob.writenl(); // ensure empty line after expansion
-        global.params.mixinLines++;
+        global.params.mixinOut.bufferLines++;
     }
     ob.writenl();
-    global.params.mixinLines++;
+    global.params.mixinOut.bufferLines++;
 
     return true;
 }
index bad071e34a5007e08add4db6c1a4da55900adc85..1c5275b3b3444dd4a1ebe7bb381db0986e84a65c 100644 (file)
@@ -53,7 +53,7 @@ bool checkUnsafeAccess(Scope* sc, Expression e, bool readonly, bool printmsg)
     {
         if (sc.intypeof || !sc.func || !sc.func.isSafeBypassingInference())
             return false;
-        auto ad = v.toParent2().isAggregateDeclaration();
+        auto ad = v.isMember2();
         if (!ad)
             return false;
 
@@ -64,23 +64,22 @@ bool checkUnsafeAccess(Scope* sc, Expression e, bool readonly, bool printmsg)
         const hasPointers = v.type.hasPointers();
         if (hasPointers)
         {
-            if (v.overlapped && sc.func.setUnsafe())
+            if (v.overlapped)
             {
-                if (printmsg)
-                    e.error("field `%s.%s` cannot access pointers in `@safe` code that overlap other fields",
-                        ad.toChars(), v.toChars());
-                return true;
+                if (sc.func.setUnsafe(!printmsg, e.loc,
+                    "field `%s.%s` cannot access pointers in `@safe` code that overlap other fields", ad, v))
+                    return true;
             }
         }
 
         if (v.type.hasInvariant())
         {
-            if (v.overlapped && sc.func.setUnsafe())
+            if (v.overlapped)
             {
-                if (printmsg)
-                    e.error("field `%s.%s` cannot access structs with invariants in `@safe` code that overlap other fields",
-                        ad.toChars(), v.toChars());
-                return true;
+                if (sc.func.setUnsafe(!printmsg, e.loc,
+                    "field `%s.%s` cannot access structs with invariants in `@safe` code that overlap other fields",
+                    ad, v))
+                    return true;
             }
         }
 
@@ -90,22 +89,22 @@ bool checkUnsafeAccess(Scope* sc, Expression e, bool readonly, bool printmsg)
         if (hasPointers && v.type.toBasetype().ty != Tstruct)
         {
             if ((!ad.type.alignment.isDefault() && ad.type.alignment.get() < target.ptrsize ||
-                 (v.offset & (target.ptrsize - 1))) &&
-                sc.func.setUnsafe())
+                 (v.offset & (target.ptrsize - 1))))
             {
-                if (printmsg)
-                    e.error("field `%s.%s` cannot modify misaligned pointers in `@safe` code",
-                        ad.toChars(), v.toChars());
-                return true;
+                if (sc.func.setUnsafe(!printmsg, e.loc,
+                    "field `%s.%s` cannot modify misaligned pointers in `@safe` code", ad, v))
+                    return true;
             }
         }
 
-        if (v.overlapUnsafe && sc.func.setUnsafe())
+        if (v.overlapUnsafe)
         {
-             if (printmsg)
-                 e.error("field `%s.%s` cannot modify fields in `@safe` code that overlap fields with other storage classes",
-                    ad.toChars(), v.toChars());
-             return true;
+            if (sc.func.setUnsafe(!printmsg, e.loc,
+                "field `%s.%s` cannot modify fields in `@safe` code that overlap fields with other storage classes",
+                ad, v))
+            {
+                return true;
+            }
         }
     }
     return false;
@@ -215,14 +214,12 @@ bool checkUnsafeDotExp(Scope* sc, Expression e, Identifier id, int flag)
     if (!(flag & DotExpFlag.noDeref) && // this use is attempting a dereference
         sc.func &&                      // inside a function
         !sc.intypeof &&                 // allow unsafe code in typeof expressions
-        !(sc.flags & SCOPE.debug_) &&   // allow unsafe code in debug statements
-        sc.func.setUnsafe())            // infer this function to be unsafe
+        !(sc.flags & SCOPE.debug_))     // allow unsafe code in debug statements
     {
         if (id == Id.ptr)
-            e.error("`%s.ptr` cannot be used in `@safe` code, use `&%s[0]` instead", e.toChars(), e.toChars());
+            return sc.func.setUnsafe(false, e.loc, "`%s.ptr` cannot be used in `@safe` code, use `&%s[0]` instead", e, e);
         else
-            e.error("`%s.%s` cannot be used in `@safe` code", e.toChars(), id.toChars());
-        return true;
+            return sc.func.setUnsafe(false, e.loc, "`%s.%s` cannot be used in `@safe` code", e, id);
     }
     return false;
 }
index cd65920e38b66009a8f16f29870700a21c34c962..73dcaa6c9608700ef400dfd48836faff1c2e5f41 100644 (file)
@@ -238,7 +238,7 @@ private extern(C++) final class Semantic2Visitor : Visitor
             return;
         }
 
-        UserAttributeDeclaration.checkGNUABITag(vd, vd.linkage);
+        UserAttributeDeclaration.checkGNUABITag(vd, vd._linkage);
 
         if (vd._init && !vd.toParent().isFuncDeclaration())
         {
@@ -379,6 +379,7 @@ private extern(C++) final class Semantic2Visitor : Visitor
             alias f1 = fd;
             auto tf1 = cast(TypeFunction) f1.type;
             auto parent1 = f1.toParent2();
+            const linkage1 = f1.resolvedLinkage();
 
             overloadApply(f1, (Dsymbol s)
             {
@@ -391,7 +392,7 @@ private extern(C++) final class Semantic2Visitor : Visitor
                     return 0;
 
                 // Functions with different manglings can never conflict
-                if (f1.linkage != f2.linkage)
+                if (linkage1 != f2.resolvedLinkage())
                     return 0;
 
                 // Functions with different names never conflict
@@ -428,12 +429,12 @@ private extern(C++) final class Semantic2Visitor : Visitor
                 // @@@DEPRECATED_2.104@@@
                 // Deprecated in 2020-08, make this an error in 2.104
                 if (parent1.isModule() &&
-                    f1.linkage != LINK.d && f1.linkage != LINK.cpp &&
+                    linkage1 != LINK.d && linkage1 != LINK.cpp &&
                     (!sameAttr || !sameParams)
                 )
                 {
                     f2.deprecation("cannot overload `extern(%s)` function at %s",
-                            linkageToChars(f1.linkage),
+                            linkageToChars(f1._linkage),
                             f1.loc.toChars());
                     return 0;
                 }
@@ -443,7 +444,7 @@ private extern(C++) final class Semantic2Visitor : Visitor
                     return 0;
 
                 // Different attributes don't conflict in extern(D)
-                if (!sameAttr && f1.linkage == LINK.d)
+                if (!sameAttr && linkage1 == LINK.d)
                     return 0;
 
                 error(f2.loc, "%s `%s%s` conflicts with previous declaration at %s",
@@ -460,7 +461,7 @@ private extern(C++) final class Semantic2Visitor : Visitor
             return;
         TypeFunction f = cast(TypeFunction) fd.type;
 
-        UserAttributeDeclaration.checkGNUABITag(fd, fd.linkage);
+        UserAttributeDeclaration.checkGNUABITag(fd, fd._linkage);
         //semantic for parameters' UDAs
         foreach (i, param; f.parameterList)
         {
@@ -643,7 +644,7 @@ private extern(C++) final class Semantic2Visitor : Visitor
                     {
                         //printf("            found\n");
                         // Check that calling conventions match
-                        if (fd.linkage != ifd.linkage)
+                        if (fd._linkage != ifd._linkage)
                             fd.error("linkage doesn't match interface function");
 
                         // Check that it is current
index 511957649f7fe7f507a4abbccbe06c540b7ae4e9..a056c99b11eedd9348a4e73dd8fd6b5d2946075b 100644 (file)
@@ -327,7 +327,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
             sc2.scontinue = null;
             sc2.sw = null;
             sc2.fes = funcdecl.fes;
-            sc2.linkage = LINK.d;
+            sc2.linkage = funcdecl.isCsymbol() ? LINK.c : LINK.d;
             sc2.stc &= STC.flowThruFunction;
             sc2.visibility = Visibility(Visibility.Kind.public_);
             sc2.explicitVisibility = 0;
@@ -1053,7 +1053,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
                         {
                             if (!v._init)
                             {
-                                v.error("Zero-length `out` parameters are not allowed.");
+                                v.error("zero-length `out` parameters are not allowed.");
                                 return;
                             }
                             ExpInitializer ie = v._init.isExpInitializer();
@@ -1277,70 +1277,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
             f.isnogc = true;
         }
 
-        if (funcdecl.flags & FUNCFLAG.returnInprocess)
-        {
-            funcdecl.flags &= ~FUNCFLAG.returnInprocess;
-            if (funcdecl.storage_class & STC.return_)
-            {
-                if (funcdecl.type == f)
-                    f = cast(TypeFunction)f.copy();
-                f.isreturn = true;
-                f.isreturnscope = cast(bool) (funcdecl.storage_class & STC.returnScope);
-                if (funcdecl.storage_class & STC.returninferred)
-                    f.isreturninferred = true;
-            }
-        }
-
-        funcdecl.flags &= ~FUNCFLAG.inferScope;
-
-        // Eliminate maybescope's
-        {
-            // Create and fill array[] with maybe candidates from the `this` and the parameters
-            VarDeclaration[10] tmp = void;
-            size_t dim = (funcdecl.vthis !is null) + (funcdecl.parameters ? funcdecl.parameters.dim : 0);
-
-            import dmd.common.string : SmallBuffer;
-            auto sb = SmallBuffer!VarDeclaration(dim, tmp[]);
-            VarDeclaration[] array = sb[];
-
-            size_t n = 0;
-            if (funcdecl.vthis)
-                array[n++] = funcdecl.vthis;
-            if (funcdecl.parameters)
-            {
-                foreach (v; *funcdecl.parameters)
-                {
-                    array[n++] = v;
-                }
-            }
-            eliminateMaybeScopes(array[0 .. n]);
-        }
-
-        // Infer STC.scope_
-        if (funcdecl.parameters && !funcdecl.errors)
-        {
-            assert(f.parameterList.length == funcdecl.parameters.dim);
-            foreach (u, p; f.parameterList)
-            {
-                auto v = (*funcdecl.parameters)[u];
-                if (v.storage_class & STC.maybescope)
-                {
-                    //printf("Inferring scope for %s\n", v.toChars());
-                    notMaybeScope(v);
-                    v.storage_class |= STC.scope_ | STC.scopeinferred;
-                    p.storageClass |= STC.scope_ | STC.scopeinferred;
-                    assert(!(p.storageClass & STC.maybescope));
-                }
-            }
-        }
-
-        if (funcdecl.vthis && funcdecl.vthis.storage_class & STC.maybescope)
-        {
-            notMaybeScope(funcdecl.vthis);
-            funcdecl.vthis.storage_class |= STC.scope_ | STC.scopeinferred;
-            f.isScopeQual = true;
-            f.isscopeinferred = true;
-        }
+        finishScopeParamInference(funcdecl, f);
 
         // reset deco to apply inference result to mangled name
         if (f != funcdecl.type)
@@ -1353,11 +1290,77 @@ private extern(C++) final class Semantic3Visitor : Visitor
             if (funcdecl.isCtorDeclaration()) // https://issues.dlang.org/show_bug.cgi?id=#15665
                 f.isctor = true;
             sc.stc = 0;
-            sc.linkage = funcdecl.linkage; // https://issues.dlang.org/show_bug.cgi?id=8496
+            sc.linkage = funcdecl._linkage; // https://issues.dlang.org/show_bug.cgi?id=8496
             funcdecl.type = f.typeSemantic(funcdecl.loc, sc);
             sc = sc.pop();
         }
 
+        // Check `extern(C++)` functions for invalid the return/parameter types
+        if (funcdecl._linkage == LINK.cpp)
+        {
+            static bool isCppNonMappableType(Type type, Parameter param = null, Type origType = null)
+            {
+                // Don't allow D `immutable` and `shared` types to be interfaced with C++
+                if (type.isImmutable() || type.isShared())
+                    return true;
+                else if (Type cpptype = target.cpp.parameterType(type))
+                    type = cpptype;
+
+                if (origType is null)
+                    origType = type;
+
+                // Permit types that are handled by toCppMangle. This list should be kept in sync with
+                // each visit method in dmd.cppmangle and dmd.cppmanglewin.
+                switch (type.ty)
+                {
+                    case Tnull:
+                    case Tnoreturn:
+                    case Tvector:
+                    case Tpointer:
+                    case Treference:
+                    case Tfunction:
+                    case Tstruct:
+                    case Tenum:
+                    case Tclass:
+                    case Tident:
+                    case Tinstance:
+                        break;
+
+                    case Tsarray:
+                        if (!origType.isTypePointer())
+                            return true;
+                        break;
+
+                    default:
+                        if (!type.isTypeBasic())
+                            return true;
+                        break;
+                }
+
+                // Descend to the enclosing type
+                if (auto tnext = type.nextOf())
+                    return isCppNonMappableType(tnext, param, origType);
+
+                return false;
+            }
+            if (isCppNonMappableType(f.next.toBasetype()))
+            {
+                funcdecl.error("cannot return type `%s` because its linkage is `extern(C++)`", f.next.toChars());
+                funcdecl.errors = true;
+            }
+            foreach (i, param; f.parameterList)
+            {
+                if (isCppNonMappableType(param.type.toBasetype(), param))
+                {
+                    funcdecl.error("cannot have parameter of type `%s` because its linkage is `extern(C++)`", param.type.toChars());
+                    if (param.type.toBasetype().isTypeSArray())
+                        errorSupplemental(funcdecl.loc, "perhaps use a `%s*` type instead",
+                                          param.type.nextOf().mutableOf().unSharedOf().toChars());
+                    funcdecl.errors = true;
+                }
+            }
+        }
+
         // Do live analysis
         if (global.params.useDIP1021 && funcdecl.fbody && funcdecl.type.ty != Terror &&
             funcdecl.type.isTypeFunction().islive)
@@ -1535,9 +1538,11 @@ private extern(C++) final class Semantic3Visitor : Visitor
 
         sc2.pop();
 
-        // don't do it for unused deprecated types
-        // or error ypes
-        if (!ad.getRTInfo && Type.rtinfo && (!ad.isDeprecated() || global.params.useDeprecated != DiagnosticReporting.error) && (ad.type && ad.type.ty != Terror))
+        // Instantiate RTInfo!S to provide a pointer bitmap for the GC
+        // Don't do it in -betterC or on unused deprecated / error types
+        if (!ad.getRTInfo && global.params.useTypeInfo && Type.rtinfo &&
+            (!ad.isDeprecated() || global.params.useDeprecated != DiagnosticReporting.error) &&
+            (ad.type && ad.type.ty != Terror))
         {
             // Evaluate: RTinfo!type
             auto tiargs = new Objects();
index 2916bbc38dd79282abfdd7bf2e426f95473e94c6..a7ad84f8504fddc6e7b246605fd0014bfbc550a6 100644 (file)
@@ -3554,13 +3554,13 @@ package (dmd) extern (C++) final class StatementSemanticVisitor : Visitor
 
         if (!global.params.useExceptions)
         {
-            tcs.error("Cannot use try-catch statements with -betterC");
+            tcs.error("cannot use try-catch statements with -betterC");
             return setError();
         }
 
         if (!ClassDeclaration.throwable)
         {
-            tcs.error("Cannot use try-catch statements because `object.Throwable` was not declared");
+            tcs.error("cannot use try-catch statements because `object.Throwable` was not declared");
             return setError();
         }
 
@@ -3762,13 +3762,13 @@ package (dmd) extern (C++) final class StatementSemanticVisitor : Visitor
     {
         if (!global.params.useExceptions)
         {
-            loc.error("Cannot use `throw` statements with -betterC");
+            loc.error("cannot use `throw` statements with -betterC");
             return false;
         }
 
         if (!ClassDeclaration.throwable)
         {
-            loc.error("Cannot use `throw` statements because `object.Throwable` was not declared");
+            loc.error("cannot use `throw` statements because `object.Throwable` was not declared");
             return false;
         }
 
@@ -3927,8 +3927,10 @@ package (dmd) extern (C++) final class StatementSemanticVisitor : Visitor
             cas.error("`asm` statement is assumed to be impure - mark it with `pure` if it is not");
         if (!(cas.stc & STC.nogc) && sc.func.setGC())
             cas.error("`asm` statement is assumed to use the GC - mark it with `@nogc` if it does not");
-        if (!(cas.stc & (STC.trusted | STC.safe)) && sc.func.setUnsafe())
-            cas.error("`asm` statement is assumed to be `@system` - mark it with `@trusted` if it is not");
+        if (!(cas.stc & (STC.trusted | STC.safe)))
+        {
+            sc.func.setUnsafe(false, cas.loc, "`asm` statement is assumed to be `@system` - mark it with `@trusted` if it is not");
+        }
 
         sc.pop();
         result = cas;
@@ -4032,10 +4034,10 @@ void catchSemantic(Catch c, Scope* sc)
             error(c.loc, "catching C++ class objects not supported for this target");
             c.errors = true;
         }
-        if (sc.func && !sc.intypeof && !c.internalCatch && sc.func.setUnsafe())
+        if (sc.func && !sc.intypeof && !c.internalCatch)
         {
-            error(c.loc, "cannot catch C++ class objects in `@safe` code");
-            c.errors = true;
+            if (sc.func.setUnsafe(false, c.loc, "cannot catch C++ class objects in `@safe` code"))
+                c.errors = true;
         }
     }
     else if (cd != ClassDeclaration.throwable && !ClassDeclaration.throwable.isBaseOf(cd, null))
@@ -4044,10 +4046,10 @@ void catchSemantic(Catch c, Scope* sc)
         c.errors = true;
     }
     else if (sc.func && !sc.intypeof && !c.internalCatch && ClassDeclaration.exception &&
-             cd != ClassDeclaration.exception && !ClassDeclaration.exception.isBaseOf(cd, null) &&
-             sc.func.setUnsafe())
+            cd != ClassDeclaration.exception && !ClassDeclaration.exception.isBaseOf(cd, null) &&
+            sc.func.setUnsafe(false, c.loc,
+                "can only catch class objects derived from `Exception` in `@safe` code, not `%s`", c.type))
     {
-        error(c.loc, "can only catch class objects derived from `Exception` in `@safe` code, not `%s`", c.type.toChars());
         c.errors = true;
     }
     else if (global.params.ehnogc)
@@ -4829,7 +4831,7 @@ private Statement toStatement(Dsymbol s)
     }
     else
     {
-        .error(Loc.initial, "Internal Compiler Error: cannot mixin %s `%s`\n", s.kind(), s.toChars());
+        .error(Loc.initial, "internal compiler error: cannot mixin %s `%s`\n", s.kind(), s.toChars());
         result = new ErrorStatement();
     }
 
index 03e80245a744a0e57422ebf4436d21d1e33ed0cf..170a5344d2b68f478bf274ab845c59237262984c 100644 (file)
@@ -608,7 +608,7 @@ static immutable TOK[TOK.max + 1] Ckeywords =
         enum Ckwds = [ auto_, break_, case_, char_, const_, continue_, default_, do_, float64, else_,
                        enum_, extern_, float32, for_, goto_, if_, inline, int32, int64, register,
                        restrict, return_, int16, signed, sizeof_, static_, struct_, switch_, typedef_,
-                       union_, unsigned, void_, volatile, while_, asm_,
+                       union_, unsigned, void_, volatile, while_, asm_, typeof_,
                        _Alignas, _Alignof, _Atomic, _Bool, _Complex, _Generic, _Imaginary, _Noreturn,
                        _Static_assert, _Thread_local, _import, __cdecl, __declspec, __stdcall, __attribute__ ];
 
index 04e1c47d16e944c8f1a5ab26f041dc4618a54d49..be954324a4e1f0ae3f3fadfbe32e240c5311e369 100644 (file)
@@ -132,6 +132,7 @@ shared static this()
         "getVirtualFunctions",
         "getVirtualMethods",
         "classInstanceSize",
+        "classInstanceAlignment",
         "allMembers",
         "derivedMembers",
         "isSame",
@@ -1211,7 +1212,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
         else
             assert(0);
     }
-    if (e.ident == Id.classInstanceSize)
+    if (e.ident == Id.classInstanceSize || e.ident == Id.classInstanceAlignment)
     {
         if (dim != 1)
             return dimError(1);
@@ -1234,7 +1235,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
             return ErrorExp.get();
         }
 
-        return new IntegerExp(e.loc, cd.structsize, Type.tsize_t);
+        return new IntegerExp(e.loc, e.ident == Id.classInstanceSize ? cd.structsize : cd.alignsize, Type.tsize_t);
     }
     if (e.ident == Id.getAliasThis)
     {
@@ -1381,7 +1382,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
                 e.error("argument to `__traits(getFunctionVariadicStyle, %s)` is not a function", o.toChars());
                 return ErrorExp.get();
             }
-            link = fd.linkage;
+            link = fd._linkage;
             varargs = fd.getParameterList().varargs;
         }
         string style;
@@ -1515,7 +1516,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
 
         if (tf)
         {
-            link = fd ? fd.linkage : tf.linkage;
+            link = fd ? fd.toAliasFunc()._linkage : tf.linkage;
         }
         else
         {
@@ -1529,7 +1530,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
             }
 
             if (d !is null)
-                link = d.linkage;
+                link = d._linkage;
             else
             {
                 // Resolves forward references
@@ -1574,7 +1575,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
         auto s = getDsymbol(o);
         if (!s)
         {
-            e.error("In expression `%s` `%s` can't have members", e.toChars(), o.toChars());
+            e.error("in expression `%s` `%s` can't have members", e.toChars(), o.toChars());
             e.errorSupplemental("`%s` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation", o.toChars());
 
             return ErrorExp.get();
@@ -1595,7 +1596,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
         auto sds = s.isScopeDsymbol();
         if (!sds || sds.isTemplateDeclaration())
         {
-            e.error("In expression `%s` %s `%s` has no members", e.toChars(), s.kind(), s.toChars());
+            e.error("in expression `%s` %s `%s` has no members", e.toChars(), s.kind(), s.toChars());
             e.errorSupplemental("`%s` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation", s.toChars());
             return ErrorExp.get();
         }
index f63b17752edd932ebdc0e2fcb19116a6ff639acc..ac4c23b06056f9bfaa72957b20cd5f51201c3056 100644 (file)
@@ -1154,7 +1154,7 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
             //printf("already done\n");
             return mtype;
         }
-        //printf("TypeFunction::semantic() this = %p\n", this);
+        //printf("TypeFunction::semantic() this = %p\n", mtype);
         //printf("TypeFunction::semantic() %s, sc.stc = %llx\n", mtype.toChars(), sc.stc);
 
         bool errors = false;
@@ -1788,111 +1788,18 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
 
     Type visitTraits(TypeTraits mtype)
     {
-        if (mtype.ty == Terror)
-            return mtype;
-
-        const inAlias = (sc.flags & SCOPE.alias_) != 0;
-        if (mtype.exp.ident != Id.allMembers &&
-            mtype.exp.ident != Id.derivedMembers &&
-            mtype.exp.ident != Id.getMember &&
-            mtype.exp.ident != Id.parent &&
-            mtype.exp.ident != Id.parameters &&
-            mtype.exp.ident != Id.child &&
-            mtype.exp.ident != Id.toType &&
-            mtype.exp.ident != Id.getOverloads &&
-            mtype.exp.ident != Id.getVirtualFunctions &&
-            mtype.exp.ident != Id.getVirtualMethods &&
-            mtype.exp.ident != Id.getAttributes &&
-            mtype.exp.ident != Id.getUnitTests &&
-            mtype.exp.ident != Id.getAliasThis)
-        {
-            static immutable (const(char)*)[2] ctxt = ["as type", "in alias"];
-            .error(mtype.loc, "trait `%s` is either invalid or not supported %s",
-                 mtype.exp.ident.toChars, ctxt[inAlias]);
-            mtype.ty = Terror;
-            return mtype;
-        }
-
-        import dmd.traits : semanticTraits;
-        Type result;
-
-        if (Expression e = semanticTraits(mtype.exp, sc))
-        {
-            switch (e.op)
-            {
-            case EXP.dotVariable:
-                mtype.sym = e.isDotVarExp().var;
-                break;
-            case EXP.variable:
-                mtype.sym = e.isVarExp().var;
-                break;
-            case EXP.function_:
-                auto fe = e.isFuncExp();
-                mtype.sym = fe.td ? fe.td : fe.fd;
-                break;
-            case EXP.dotTemplateDeclaration:
-                mtype.sym = e.isDotTemplateExp().td;
-                break;
-            case EXP.dSymbol:
-                mtype.sym = e.isDsymbolExp().s;
-                break;
-            case EXP.template_:
-                mtype.sym = e.isTemplateExp().td;
-                break;
-            case EXP.scope_:
-                mtype.sym = e.isScopeExp().sds;
-                break;
-            case EXP.tuple:
-                TupleExp te = e.isTupleExp();
-                Objects* elems = new Objects(te.exps.dim);
-                foreach (i; 0 .. elems.dim)
-                {
-                    auto src = (*te.exps)[i];
-                    switch (src.op)
-                    {
-                    case EXP.type:
-                        (*elems)[i] = src.isTypeExp().type;
-                        break;
-                    case EXP.dotType:
-                        (*elems)[i] = src.isDotTypeExp().sym.isType();
-                        break;
-                    case EXP.overloadSet:
-                        (*elems)[i] = src.isOverExp().type;
-                        break;
-                    default:
-                        if (auto sym = isDsymbol(src))
-                            (*elems)[i] = sym;
-                        else
-                            (*elems)[i] = src;
-                    }
-                }
-                TupleDeclaration td = new TupleDeclaration(e.loc, Identifier.generateId("__aliastup"), elems);
-                mtype.sym = td;
-                break;
-            case EXP.dotType:
-                result = e.isDotTypeExp().sym.isType();
-                break;
-            case EXP.type:
-                result = e.isTypeExp().type;
-                break;
-            case EXP.overloadSet:
-                result = e.isOverExp().type;
-                break;
-            default:
-                break;
-            }
-        }
+        Expression e;
+        Type t;
+        Dsymbol s;
+        mtype.resolve(loc, sc, e, t, s);
 
-        if (result)
-            result = result.addMod(mtype.mod);
-        if (!inAlias && !result)
+        if (!t)
         {
             if (!global.errors)
                 .error(mtype.loc, "`%s` does not give a valid type", mtype.toChars);
             return error();
         }
-
-        return result;
+        return t;
     }
 
     Type visitReturn(TypeReturn mtype)
@@ -3132,7 +3039,8 @@ void resolve(Type mt, const ref Loc loc, Scope* sc, out Expression pe, out Type
         if (mt.exp.op == EXP.type ||
             mt.exp.op == EXP.scope_)
         {
-            if (mt.exp.checkType())
+            if (!(sc.flags & SCOPE.Cfile) && // in (extended) C typeof may be used on types as with sizeof
+                mt.exp.checkType())
                 goto Lerr;
 
             /* Today, 'typeof(func)' returns void if func is a
@@ -3326,14 +3234,99 @@ void resolve(Type mt, const ref Loc loc, Scope* sc, out Expression pe, out Type
         mt.obj = pe ? pe : (pt ? pt : ps);
     }
 
-    void visitTraits(TypeTraits tt)
+    void visitTraits(TypeTraits mt)
     {
-        if (Type t = typeSemantic(tt, loc, sc))
-            returnType(t);
-        else if (tt.sym)
-            returnSymbol(tt.sym);
+        // if already resolved just return the cached object.
+        if (mt.obj)
+        {
+            pt = mt.obj.isType();
+            ps = mt.obj.isDsymbol();
+            return;
+        }
+
+        import dmd.traits : semanticTraits;
+
+        if (Expression e = semanticTraits(mt.exp, sc))
+        {
+            switch (e.op)
+            {
+            case EXP.dotVariable:
+                mt.obj = e.isDotVarExp().var;
+                break;
+            case EXP.variable:
+                mt.obj = e.isVarExp().var;
+                break;
+            case EXP.function_:
+                auto fe = e.isFuncExp();
+                mt.obj = fe.td ? fe.td : fe.fd;
+                break;
+            case EXP.dotTemplateDeclaration:
+                mt.obj = e.isDotTemplateExp().td;
+                break;
+            case EXP.dSymbol:
+                mt.obj = e.isDsymbolExp().s;
+                break;
+            case EXP.template_:
+                mt.obj = e.isTemplateExp().td;
+                break;
+            case EXP.scope_:
+                mt.obj = e.isScopeExp().sds;
+                break;
+            case EXP.tuple:
+                TupleExp te = e.isTupleExp();
+                Objects* elems = new Objects(te.exps.dim);
+                foreach (i; 0 .. elems.dim)
+                {
+                    auto src = (*te.exps)[i];
+                    switch (src.op)
+                    {
+                    case EXP.type:
+                        (*elems)[i] = src.isTypeExp().type;
+                        break;
+                    case EXP.dotType:
+                        (*elems)[i] = src.isDotTypeExp().sym.isType();
+                        break;
+                    case EXP.overloadSet:
+                        (*elems)[i] = src.isOverExp().type;
+                        break;
+                    default:
+                        if (auto sym = isDsymbol(src))
+                            (*elems)[i] = sym;
+                        else
+                            (*elems)[i] = src;
+                    }
+                }
+                TupleDeclaration td = new TupleDeclaration(e.loc, Identifier.generateId("__aliastup"), elems);
+                mt.obj = td;
+                break;
+            case EXP.dotType:
+                mt.obj = e.isDotTypeExp().sym.isType();
+                break;
+            case EXP.type:
+                mt.obj = e.isTypeExp().type;
+                break;
+            case EXP.overloadSet:
+                mt.obj = e.isOverExp().type;
+                break;
+            default:
+                break;
+            }
+        }
+
+        if (mt.obj)
+        {
+            if (auto t = mt.obj.isType())
+                returnType(t.addMod(mt.mod));
+            else if (auto s = mt.obj.isDsymbol())
+                returnSymbol(s);
+            else
+                assert(0);
+        }
         else
+        {
+            mt.obj = Type.terror;
             return returnError();
+        }
     }
 
     switch (mt.ty)
@@ -3391,7 +3384,7 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag)
                 v.dsymbolSemantic(null);
                 if (v.isField())
                 {
-                    auto ad = v.toParent().isAggregateDeclaration();
+                    auto ad = v.isMember();
                     objc.checkOffsetof(e, ad);
                     ad.size(e.loc);
                     if (ad.sizeok != Sizeok.done)
@@ -3637,12 +3630,16 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag)
             }
             else
             {
+                Expression e0;
+                Expression ev = e;
+                ev = extractSideEffect(sc, "__tup", e0, ev);
+
                 const length = cast(size_t)mt.dim.toUInteger();
                 auto exps = new Expressions();
                 exps.reserve(length);
                 foreach (i; 0 .. length)
-                    exps.push(new IndexExp(e.loc, e, new IntegerExp(e.loc, i, Type.tsize_t)));
-                e = new TupleExp(e.loc, exps);
+                    exps.push(new IndexExp(e.loc, ev, new IntegerExp(e.loc, i, Type.tsize_t)));
+                e = new TupleExp(e.loc, e0, exps);
             }
         }
         else
index 7f3fb64842d634f0bc6f96d4b472287845a345b7..5be4a196345ee5c4a61a9803292b7abe9eb40adf 100644 (file)
@@ -84,7 +84,7 @@ extern (D) void writeFile(Loc loc, const(char)[] filename, const void[] data)
     ensurePathToNameExists(Loc.initial, filename);
     if (!File.update(filename, data))
     {
-        error(loc, "Error writing file '%.*s'", cast(int) filename.length, filename.ptr);
+        error(loc, "error writing file '%.*s'", cast(int) filename.length, filename.ptr);
         fatal();
     }
 }
index c683d9da333da36724998a5bee87385b263de0a2..7f5e683a676d3142bd5ec32f799c8c9cd457228d 100644 (file)
@@ -847,53 +847,10 @@ public:
       }
     else
       {
+       /* Appending an element or array to another array has already been
+          handled by the front-end.  */
        gcc_assert (tb1->ty == TY::Tarray || tb2->ty == TY::Tsarray);
-
-       if ((tb2->ty == TY::Tarray || tb2->ty == TY::Tsarray)
-           && same_type_p (etype, tb2->nextOf ()->toBasetype ()))
-         {
-           /* Append an array to another array:
-              The assignment is handled by the D run-time library, so only
-              need to call `_d_arrayappendT(ti, &e1, e2)'  */
-           result = build_libcall (LIBCALL_ARRAYAPPENDT, e->type, 3,
-                                   build_typeinfo (e->loc, e->type),
-                                   ptr, d_array_convert (e->e2));
-         }
-       else if (same_type_p (etype, tb2))
-         {
-           /* Append an element to an array:
-              The assignment is generated inline, so need to handle temporaries
-              here, and ensure that they are evaluated in the correct order.
-
-              The generated code should end up being equivalent to:
-                   _d_arrayappendcTX(ti, &e1, 1)[e1.length - 1] = e2
-            */
-           tree callexp = build_libcall (LIBCALL_ARRAYAPPENDCTX, e->type, 3,
-                                         build_typeinfo (e->loc, e->type),
-                                         ptr, size_one_node);
-           callexp = d_save_expr (callexp);
-
-           /* Assign e2 to last element.  */
-           tree offexp = d_array_length (callexp);
-           offexp = build2 (MINUS_EXPR, TREE_TYPE (offexp),
-                            offexp, size_one_node);
-
-           tree ptrexp = d_array_ptr (callexp);
-           ptrexp = void_okay_p (ptrexp);
-           ptrexp = build_array_index (ptrexp, offexp);
-
-           /* Evaluate expression before appending.  */
-           tree rhs = build_expr (e->e2);
-           tree rexpr = stabilize_expr (&rhs);
-
-           if (TREE_CODE (rhs) == CALL_EXPR)
-             rhs = force_target_expr (rhs);
-
-           result = modify_expr (build_deref (ptrexp), rhs);
-           result = compound_expr (rexpr, result);
-         }
-       else
-         gcc_unreachable ();
+       gcc_unreachable ();
       }
 
     /* Construct in order: ptr = &e1, _d_arrayappend(ptr, e2), *ptr;  */
index b4b81523c14f3856daf16fa3db195a9433b83355..c2635827ad3896c8142b1964d48ab27ad9529f1e 100644 (file)
@@ -340,6 +340,10 @@ fpreview=all
 D RejectNegative
 Turn on all upcoming D language features.
 
+fpreview=bitfields
+D RejectNegative
+Implement D bit-fields.
+
 fpreview=dip1000
 D RejectNegative
 Implement DIP1000: Scoped pointers.
@@ -412,10 +416,6 @@ frevert=intpromote
 D RejectNegative
 Use C-style integral promotion for unary '+', '-' and '~'.
 
-frevert=markdown
-D RejectNegative
-Disable Markdown replacements in Ddoc.
-
 frtti
 D
 ; Documented in C
@@ -452,10 +452,6 @@ ftransition=tls
 D RejectNegative
 List all variables going into thread local storage.
 
-ftransition=vmarkdown
-D RejectNegative
-List instances of Markdown replacements in Ddoc.
-
 funittest
 D
 Compile in unittest code.
index d897ec4c5e42d80c33b802b1d91faedee558b8bd..c54049dfb984c815dd8efad8dd61f358db8efcd1 100644 (file)
@@ -375,7 +375,7 @@ fixup_anonymous_offset (tree fields, tree offset)
 
 /* Iterate over all MEMBERS of an aggregate, and add them as fields to CONTEXT.
    If INHERITED_P is true, then the members derive from a base class.
-   Returns the number of fields found.  */
+   Returns the number of named fields found.  */
 
 static size_t
 layout_aggregate_members (Dsymbols *members, tree context, bool inherited_p)
@@ -418,7 +418,8 @@ layout_aggregate_members (Dsymbols *members, tree context, bool inherited_p)
          /* Insert the field declaration at its given offset.  */
          if (var->isField ())
            {
-             const char *ident = var->ident ? var->ident->toChars () : NULL;
+             const char *ident = (var->ident && !var->ident->isAnonymous ())
+               ? var->ident->toChars () : NULL;
              tree field = create_field_decl (declaration_type (var), ident,
                                              inherited_p, inherited_p);
              apply_user_attributes (var, field);
@@ -442,7 +443,10 @@ layout_aggregate_members (Dsymbols *members, tree context, bool inherited_p)
                  var->csym = field;
                }
 
-             fields += 1;
+             /* Only count the named fields in an aggregate.  */
+             if (ident != NULL)
+               fields += 1;
+
              continue;
            }
        }
index 0c727e2fec560a81ee1d63b857f4c86a076e765a..7db9531e7565bc4b22c225dd25e37c2e27639a7c 100644 (file)
@@ -24,8 +24,8 @@ class C2 // overall alignment: max(vtbl.alignof, monitor.alignof, 1, 2)
 
 enum payloadOffset = C2.bytes.offsetof;
 static assert(C2.int1.offsetof == payloadOffset + 8);
-static assert(C2.alignof == size_t.sizeof);
-static assert(__traits(classInstanceSize, C2) == payloadOffset + 12);
+static assert(__traits(classInstanceAlignment, C2) == size_t.sizeof);
+static assert(__traits(classInstanceSize, C2) == payloadOffset + 12); // no tail padding
 
 align(8) struct PaddedStruct
 {
@@ -37,6 +37,15 @@ static assert(PaddedStruct.s1.offsetof == 2);
 static assert(PaddedStruct.alignof == 8);
 static assert(PaddedStruct.sizeof == 16);
 
+class AlignedPayloadClass
+{
+    align(64) int field;
+}
+
+static assert(AlignedPayloadClass.field.offsetof == 64); // vtbl, monitor, alignment padding
+static assert(__traits(classInstanceAlignment, AlignedPayloadClass) == 64);
+static assert(__traits(classInstanceSize, AlignedPayloadClass) == 68);
+
 align(1) struct UglyStruct
 {
     bool flag;
index 40fba4815ca0787e5af835369d37848e1bb0c412..4678eb533864e2f7ade6dc00c8b50fb0a3b2cc81 100644 (file)
@@ -3,7 +3,7 @@
 // EXTRA_FILES: imports/a12506.d
 /* TEST_OUTPUT:
 ---
-compilable/compile1.d(229): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
+compilable/compile1.d(230): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
 ---
 */
 
index 8c112d1e5485e43adbc13fdd230bc1a38ad6e1c8..fc74c944cad04a26bf4b677327c4005b14b013d9 100644 (file)
@@ -1327,3 +1327,8 @@ extern (C++)
             static assert(funccpp.mangleof == "?funccpp@@YAHP6AXXZ@Z");
     }
 }
+
+/*****************************************/
+
+extern(C++) enum _LIBNAME = "library";
+extern(C++) enum _DEBUG = _LIBNAME.length && 'd' == _LIBNAME[$-1];
diff --git a/gcc/testsuite/gdc.test/compilable/dbitfield.d b/gcc/testsuite/gdc.test/compilable/dbitfield.d
new file mode 100644 (file)
index 0000000..e2883fd
--- /dev/null
@@ -0,0 +1,88 @@
+/* REQUIRED_ARGS: -preview=bitfields
+ */
+
+/***************************************************/
+
+class C
+{
+    uint a:3;
+    uint b:1;
+    ulong c:64;
+
+    int d:3;
+    int e:1;
+    long f:64;
+
+    int i;
+}
+
+static assert(C.a.min == 0);
+static assert(C.a.max == 7);
+
+static assert(C.b.min == 0);
+static assert(C.b.max == 1);
+
+static assert(C.c.min == 0);
+static assert(C.c.max == ulong.max);
+
+static assert(C.d.min == -4);
+static assert(C.d.max == 3);
+
+static assert(C.e.min == -1);
+static assert(C.e.max == 0);
+
+static assert(C.f.min == long.min);
+static assert(C.f.max == long.max);
+
+int testc()
+{
+    scope c = new C();
+    c.d = 9;
+    return c.d;
+}
+
+static assert(testc() == 1);
+
+/***************************************************/
+
+union U
+{
+    uint a:3;
+    uint b:1;
+    ulong c:64;
+
+    int d:3;
+    int e:1;
+    long f:64;
+
+    int i;
+}
+
+static assert(U.sizeof == 8);
+
+static assert(U.a.min == 0);
+static assert(U.a.max == 7);
+
+static assert(U.b.min == 0);
+static assert(U.b.max == 1);
+
+static assert(U.c.min == 0);
+static assert(U.c.max == ulong.max);
+
+static assert(U.d.min == -4);
+static assert(U.d.max == 3);
+
+static assert(U.e.min == -1);
+static assert(U.e.max == 0);
+
+static assert(U.f.min == long.min);
+static assert(U.f.max == long.max);
+
+int testu()
+{
+    U u;
+    u.d = 9;
+    return u.d;
+}
+
+static assert(testu() == 1);
diff --git a/gcc/testsuite/gdc.test/compilable/ddoc_markdown_breaks_verbose.d b/gcc/testsuite/gdc.test/compilable/ddoc_markdown_breaks_verbose.d
deleted file mode 100644 (file)
index 1ff26b0..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// PERMUTE_ARGS:
-// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -wi -o- -transition=vmarkdown
-// OUTPUT_FILES: ${RESULTS_DIR}/compilable/ddoc_markdown_breaks_verbose.html
-// TEST_OUTPUT_FILE: extra-files/ddoc_markdown_breaks_verbose.html
-
-/++
-Thematic Breaks
-
-___
-- - -
-***
-+/
-module ddoc_markdown_breaks;
diff --git a/gcc/testsuite/gdc.test/compilable/ddoc_markdown_code_verbose.d b/gcc/testsuite/gdc.test/compilable/ddoc_markdown_code_verbose.d
deleted file mode 100644 (file)
index eb64c04..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// PERMUTE_ARGS:
-// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- -transition=vmarkdown
-// TEST_OUTPUT_FILE: extra-files/ddoc_markdown_code_verbose.html
-// OUTPUT_FILES: ${RESULTS_DIR}/compilable/ddoc_markdown_code_verbose.html
-
-/++
-Code:
-
-``` ruby red
-RWBY
-```
-+/
-module test.compilable.ddoc_markdown_code_verbose;
diff --git a/gcc/testsuite/gdc.test/compilable/ddoc_markdown_emphasis_verbose.d b/gcc/testsuite/gdc.test/compilable/ddoc_markdown_emphasis_verbose.d
deleted file mode 100644 (file)
index 07904c1..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// PERMUTE_ARGS:
-// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -wi -o- -transition=vmarkdown
-// TEST_OUTPUT_FILE: extra-files/ddoc_markdown_emphasis_verbose.html
-// OUTPUT_FILES: ${RESULTS_DIR}/compilable/ddoc_markdown_emphasis_verbose.html
-
-/++
-Markdown Emphasis:
-
-*emphasized text*
-
-**strongly emphasized text**
-+/
-module ddoc_markdown_emphasis;
diff --git a/gcc/testsuite/gdc.test/compilable/ddoc_markdown_headings_verbose.d b/gcc/testsuite/gdc.test/compilable/ddoc_markdown_headings_verbose.d
deleted file mode 100644 (file)
index 6448463..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// PERMUTE_ARGS:
-// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- -transition=vmarkdown
-// TEST_OUTPUT_FILE: extra-files/ddoc_markdown_headings_verbose.html
-// OUTPUT_FILES: ${RESULTS_DIR}/compilable/ddoc_markdown_headings_verbose.html
-
-/++
-# Heading
-+/
-module ddoc_markdown_headings_verbose;
diff --git a/gcc/testsuite/gdc.test/compilable/ddoc_markdown_links_verbose.d b/gcc/testsuite/gdc.test/compilable/ddoc_markdown_links_verbose.d
deleted file mode 100644 (file)
index 435b426..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// PERMUTE_ARGS:
-// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- -transition=vmarkdown
-// TEST_OUTPUT_FILE: extra-files/ddoc_markdown_links_verbose.html
-// OUTPUT_FILES: ${RESULTS_DIR}/compilable/ddoc_markdown_links_verbose.html
-
-/++
-Links:
-
-A link to [Object].
-An inline link to [the D homepage](https://dlang.org).
-A simple link to [dub].
-A slightly less simple link to [dub][].
-An image: ![D-Man](https://dlang.org/images/d3.png)
-
-[dub]: https://code.dlang.org
-+/
-module test.compilable.ddoc_markdown_links_verbose;
diff --git a/gcc/testsuite/gdc.test/compilable/ddoc_markdown_lists_verbose.d b/gcc/testsuite/gdc.test/compilable/ddoc_markdown_lists_verbose.d
deleted file mode 100644 (file)
index 4fd1a80..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// PERMUTE_ARGS:
-// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- -transition=vmarkdown
-// TEST_OUTPUT_FILE: extra-files/ddoc_markdown_lists_verbose.html
-// OUTPUT_FILES: ${RESULTS_DIR}/compilable/ddoc_markdown_lists_verbose.html
-
-/++
-- list item
-+/
-module ddoc_markdown_lists_verbose;
diff --git a/gcc/testsuite/gdc.test/compilable/ddoc_markdown_quote_verbose.d b/gcc/testsuite/gdc.test/compilable/ddoc_markdown_quote_verbose.d
deleted file mode 100644 (file)
index f16e539..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// PERMUTE_ARGS:
-// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- -transition=vmarkdown
-// TEST_OUTPUT_FILE: extra-files/ddoc_markdown_quote_verbose.html
-// OUTPUT_FILES: ${RESULTS_DIR}/compilable/ddoc_markdown_quote_verbose.html
-
-/++
-Quote Block:
-
-> Great, just what I need.. another D in programming. -- Segfault
-+/
-module test.compilable.ddoc_markdown_code_verbose;
diff --git a/gcc/testsuite/gdc.test/compilable/ddoc_markdown_tables_verbose.d b/gcc/testsuite/gdc.test/compilable/ddoc_markdown_tables_verbose.d
deleted file mode 100644 (file)
index d1aac1c..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// PERMUTE_ARGS:
-// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- -transition=vmarkdown
-// TEST_OUTPUT_FILE: extra-files/ddoc_markdown_tables_verbose.html
-// OUTPUT_FILES: ${RESULTS_DIR}/compilable/ddoc_markdown_tables_verbose.html
-
-/++
-Table:
-
-| this | that |
-| ---- | ---- |
-| cell | cell |
-+/
-module test.compilable.ddoc_markdown_tables_verbose;
index 8836ad1f4690158cee123273feb682a679347492..3e535d24a06cd261b25fd2e33e86452a793a1430 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 10f5807f5c30266b8938d263959f28f17d9d6b4b..64198f91a217bf3f7a6ba11d17d0ff927ff3f762 100644 (file)
@@ -10,9 +10,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 1499d04335105deeecbc64ede6ee21160ab0dd62..12edbd2392318eed2dc025834ff2b236aa035991 100644 (file)
@@ -7,9 +7,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 9d686312800f53cb94b60a0ac81f4f91b0221cb1..20134f5b44961a586dce943b1e993c1715c09cd7 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 6995a6752565d0ba08f67c2d6c3d8eb5dce271f9..870387c7113e61e1218a4b007e8c82358e47f0c2 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 4f13d2bc9e18588752dd89e80805c8c23b317def..de4c7ba4247d4bd50b13a41f4aa821d42e79407b 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 4d56c7c556942d2e84cd93387e1227c8c925750a..8c7ba9be672857bcd0108fa77a9224aa93aa8652 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index e9e57da87f02b542db24b09e3d1215e1317cdc8d..35c4ed7e03f112696bf4e494846c1fb8f846de3c 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index b609cc28a44ba772793c3b7c22b599f9559ad122..48fcf72c0611db8f932f181dcd3bb5889a783749 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 7356ba3f6bd849253fb41d095bbe2be916df51da..1faa51e63fb28a6dc68b84bd5ed60f915976d918 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index b291cf6e2950ba37fd0610f82af49b47748c937c..cf1ae483772f4cacd58703dbc2a4196f39d96568 100644 (file)
@@ -10,9 +10,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 6a0dfd92f658ccbebc3953ee80d19709fcaa5b20..8b3e5aa3873d3a98e78e820012b757b0822ba8eb 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 2330d76c67074c00c215200db516076dd722258a..6a266d9be77e0a38b9dc83edd1de087891223daa 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 7919c6771ee3b361dea93e713b7278247d23059e..b93c47e081374237ea4e6ee702a1f51c9c670cb9 100644 (file)
@@ -7,9 +7,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 0426a5e9dfe80e26c559efa8a3bae0907aa7b9ea..83ac67d6f32170d97f10970185799f02fae30020 100644 (file)
@@ -9,9 +9,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 2f5b7dfe68d51abfafa7df6b43c98b4933247b4b..c9d5bbc796ebe6243b730264cce117e4f157832f 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 1ee6ce62c48b38ec1ac6bd41d49f524e913633b8..1feff408adcee0d84bb8b25560a3b61b86834547 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
@@ -79,6 +79,8 @@ extern size_t baz5(size_t x = 42);
 
 extern size_t& bazRef(size_t& x);
 
+extern size_t bazOut(size_t& x);
+
 enum class E : int64_t
 {
     m = 1LL,
@@ -219,6 +221,11 @@ extern (C++) ref size_t bazRef(return ref size_t x)
     return x;
 }
 
+extern (C++) size_t bazOut(out size_t x)
+{
+    return x;
+}
+
 extern (C++):
 
 enum E : long
index d687673accea14ce9bc0803f35513f736c52d093..d162a324b9a13cfb3e3993eeca775118fa8b1943 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index c7d4c14e0c7a8baced058e8642d3e1c039f4d491..b8e8d05649cda8568029a653362d16b95ac392c0 100644 (file)
@@ -17,9 +17,9 @@ compilable/dtoh_invalid_identifiers.d(145): Warning: function `__attribute__` is
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 44d0dd5be9b36a811b1a330eab0fb907de5fb945..10967c831374bded09cfafe70200c455dde05759 100644 (file)
@@ -7,9 +7,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 8a7eb7ffffba946104cd9c6b04220f14250c46c4..a4b055e4097e6b7295f9813244f8e14796ca4db1 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 2180c4134a3841e2efa19e61d914256a57693786..3fd54c7de7478e149b83e5cf86307d0f8c28921a 100644 (file)
@@ -9,9 +9,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index d41cb1bc2138fa203c12acb4787f4e37c5a1f590..ab5376424f9898ae8c6b1eef9c64f9d88fddcf4a 100644 (file)
@@ -7,9 +7,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index a7c0a0d3f0a106a97c528ee4e92733373f9af2ef..37b450703a929b38c2ca174418878ace7ce4e56f 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index ac58d0e803f328bb740764ce5717241e3c6748e5..7b2943c5fc50c4935593b7dff2b00910dc97ccec 100644 (file)
@@ -8,9 +8,9 @@ TEST_OUTPUT:
 #pragma once
 
 #include <assert.h>
+#include <math.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <math.h>
 
 #ifdef CUSTOM_D_ARRAY_TYPE
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
index 505ffdc49988977f5dcc74ec0d227c0f1a26764d..891ff0ebd4839bbb2f34ce66613dae2c19816c51 100644 (file)
@@ -10,9 +10,9 @@ TEST_OUTPUT:
 #pragma once\r
 \r
 #include <assert.h>\r
+#include <math.h>\r
 #include <stddef.h>\r
 #include <stdint.h>\r
-#include <math.h>\r
 \r
 #ifdef CUSTOM_D_ARRAY_TYPE\r
 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE\r
index 6eec76f7423e6e7ebe64e504281be79ad20ef331..3e00e9f0af6f1bb09cace12793df285cf2e91427 100644 (file)
@@ -1,4 +1,4 @@
-// REQUIRED_ARGS: -o-
+// REQUIRED_ARGS: -o- -preview=dip1000
 
 void lazyfun(scope lazy int a) @nogc;
 
diff --git a/gcc/testsuite/gdc.test/compilable/test20427.d b/gcc/testsuite/gdc.test/compilable/test20427.d
new file mode 100644 (file)
index 0000000..074ed12
--- /dev/null
@@ -0,0 +1,3 @@
+// https://issues.dlang.org/show_bug.cgi?id=20427
+extern(C++) void test20427(T)(T) {}
+static assert(!__traits(compiles, { test20427([1, 2]); }));
diff --git a/gcc/testsuite/gdc.test/compilable/test23047.d b/gcc/testsuite/gdc.test/compilable/test23047.d
new file mode 100644 (file)
index 0000000..e1ac3e7
--- /dev/null
@@ -0,0 +1,13 @@
+/* REQUIRED_ARGS: -defaultlib= -c -O
+ */
+
+// https://issues.dlang.org/show_bug.cgi?id=23047
+version(D_SIMD):
+alias long2 = __vector(long[2]);
+
+long2 _mm_srl_epi64 ()
+{
+    long2 r = void;
+    r[0] = 1;
+    return r;
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test23087.d b/gcc/testsuite/gdc.test/compilable/test23087.d
new file mode 100644 (file)
index 0000000..6927ddf
--- /dev/null
@@ -0,0 +1,9 @@
+// https://issues.dlang.org/show_bug.cgi?id=23087
+struct S
+{
+    this(bool) {}
+    this(bool, int) {}
+}
+
+static foreach (ctor; __traits(getOverloads, S, "__ctor"))
+    static assert(__traits(getLinkage, ctor) == "D");
diff --git a/gcc/testsuite/gdc.test/compilable/test23089.d b/gcc/testsuite/gdc.test/compilable/test23089.d
new file mode 100644 (file)
index 0000000..1bc2913
--- /dev/null
@@ -0,0 +1,7 @@
+// https://issues.dlang.org/show_bug.cgi?id=23089
+extern(System) int i23089;
+
+extern(System):
+
+alias F23089 = void function(int);
+F23089 f23089;
diff --git a/gcc/testsuite/gdc.test/compilable/test23097.d b/gcc/testsuite/gdc.test/compilable/test23097.d
new file mode 100644 (file)
index 0000000..092bd77
--- /dev/null
@@ -0,0 +1,33 @@
+/* https://issues.dlang.org/show_bug.cgi?id=23097
+REQUIRED_ARGS: -verrors=spec
+TEST_OUTPUT:
+---
+(spec:2) compilable/test23097.d(14): Error: `inout` constructor `test23097.S23097.this` creates const object, not mutable
+(spec:2) compilable/test23097.d(14): Error: `inout` constructor `test23097.S23097.this` creates const object, not mutable
+(spec:1) compilable/test23097.d(14): Error: generated function `test23097.S23097.opAssign(S23097 p)` is not callable using argument types `(const(S23097))`
+(spec:2) compilable/test23097.d(14): Error: `inout` constructor `test23097.S23097.this` creates const object, not mutable
+(spec:1) compilable/test23097.d(14):        `struct S23097` does not define a copy constructor for `const(S23097)` to `S23097` copies
+---
+*/
+void emplaceRef(UT, Args)(UT chunk, Args args)
+{
+    static if (__traits(compiles, chunk = args))
+        chunk = args;
+}
+
+struct CpCtor23097(T)
+{
+    T* payload;
+    this(ref inout typeof(this)) { }
+    ref opAssign(typeof(this)) { }
+}
+
+struct S23097
+{
+    CpCtor23097!int payload;
+}
+
+void test23097(S23097 lhs, const S23097 rhs)
+{
+    emplaceRef(lhs, rhs);
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test23105.d b/gcc/testsuite/gdc.test/compilable/test23105.d
new file mode 100644 (file)
index 0000000..8595e37
--- /dev/null
@@ -0,0 +1,6 @@
+// https://issues.dlang.org/show_bug.cgi?id=23105
+
+module test23105;
+
+static assert(is(mixin(`__traits(getMember, test23105, "object")`) == module));
+static assert(is(__traits(getMember, test23105, "object") == module)); // Fixed
index baa0cd76a35c4ec38cd146f51fd659235f6f58da..9912b88e5ff04d226116f7093679049125af7c59 100644 (file)
@@ -1,13 +1,15 @@
 // https://issues.dlang.org/show_bug.cgi?id=3004
 /*
 REQUIRED_ARGS: -ignore -v
-TRANSFORM_OUTPUT: remove_lines("^(predefs|binary|version|config|DFLAG|parse|import|semantic|entry|function  object|\s*$)")
+TRANSFORM_OUTPUT: remove_lines("^(predefs|binary|version|config|DFLAG|parse|import|semantic|entry|library|function  object|\s*$)")
 TEST_OUTPUT:
 ---
 pragma    GNU_attribute (__error)
 pragma    GNU_attribute (__error)
 code      test3004
 function  test3004.test
+function  core.internal.array.appending._d_arrayappendcTXImpl!(char[], char)._d_arrayappendcTX
+function  core.internal.array.utils._d_HookTraceImpl!(char[], _d_arrayappendcTX, "Cannot append to array if compiling without support for runtime type information!")._d_HookTraceImpl
 ---
 */
 
index 46736772730a33b89a4ae5f31be262e6b5f79143..cbb150cb1d5a4113080489acc057276c5a13ffb0 100644 (file)
@@ -52,8 +52,7 @@ alias wchar_t = __c_wchar_t;
 
 T[] values(T)()
 {
-    T[] values;
-    values ~= T();
+    T[] values = [T()];
     return values;
 }
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/attributediagnostic.d b/gcc/testsuite/gdc.test/fail_compilation/attributediagnostic.d
new file mode 100644 (file)
index 0000000..1fdf5a5
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/attributediagnostic.d(16): Error: `@safe` function `attributediagnostic.layer2` cannot call `@system` function `attributediagnostic.layer1`
+fail_compilation/attributediagnostic.d(18):        which calls `attributediagnostic.layer0`
+fail_compilation/attributediagnostic.d(20):        which calls `attributediagnostic.system`
+fail_compilation/attributediagnostic.d(22):        which was inferred `@system` because of:
+fail_compilation/attributediagnostic.d(22):        `asm` statement is assumed to be `@system` - mark it with `@trusted` if it is not
+fail_compilation/attributediagnostic.d(17):        `attributediagnostic.layer1` is declared here
+---
+*/
+
+// Issue 17374 - Improve inferred attribute error message
+// https://issues.dlang.org/show_bug.cgi?id=17374
+
+auto layer2() @safe { layer1(); }
+auto layer1() { layer0(); }
+auto layer0() { system(); }
+
+auto system()
+{
+       asm {}
+}
index a9b2a505b89248dcf1b75c09641a63dbcd64eb8b..c975a436e6dbbfd0e8596ab425b54ab2d850923e 100644 (file)
@@ -1,8 +1,8 @@
 /* TEST_OUTPUT:
 ---
-fail_compilation/b6227.d(16): Error: Comparison between different enumeration types `X` and `Y`; If this behavior is intended consider using `std.conv.asOriginalType`
+fail_compilation/b6227.d(16): Error: comparison between different enumeration types `X` and `Y`; If this behavior is intended consider using `std.conv.asOriginalType`
 fail_compilation/b6227.d(16):        while evaluating: `static assert(!(X.O != Y.U))`
-fail_compilation/b6227.d(17): Error: Comparison between different enumeration types `X` and `Y`; If this behavior is intended consider using `std.conv.asOriginalType`
+fail_compilation/b6227.d(17): Error: comparison between different enumeration types `X` and `Y`; If this behavior is intended consider using `std.conv.asOriginalType`
 fail_compilation/b6227.d(17):        while evaluating: `static assert(X.O == Y.U)`
 ---
 */
index e1cc4cf04d2854aa6dd08f446b4dae3abe13c494..6f4fb036b7f076d5629844a9b16ad9ecd0b45ff7 100644 (file)
@@ -1,8 +1,8 @@
 /* REQUIRED_ARGS: -betterC
  * TEST_OUTPUT:
 ---
-fail_compilation/betterc.d(12): Error: Cannot use `throw` statements with -betterC
-fail_compilation/betterc.d(17): Error: Cannot use try-catch statements with -betterC
+fail_compilation/betterc.d(12): Error: cannot use `throw` statements with -betterC
+fail_compilation/betterc.d(17): Error: cannot use try-catch statements with -betterC
 fail_compilation/betterc.d(29): Error: `TypeInfo` cannot be used with -betterC
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/biterrors.d b/gcc/testsuite/gdc.test/fail_compilation/biterrors.d
new file mode 100644 (file)
index 0000000..a8f0faa
--- /dev/null
@@ -0,0 +1,15 @@
+/* REQUIRED_ARGS: -preview=bitfields
+ * TEST_OUTPUT:
+---
+fail_compilation/biterrors.d(103): Error: initializer not allowed for bit-field declaration
+fail_compilation/biterrors.d(104): Error: storage class not allowed for bit-field declaration
+---
+ */
+
+#line 100
+
+struct S
+{
+    int i : 3 = 7;
+    static int j : 3;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/biterrors2.d b/gcc/testsuite/gdc.test/fail_compilation/biterrors2.d
new file mode 100644 (file)
index 0000000..c8390ba
--- /dev/null
@@ -0,0 +1,17 @@
+/* REQUIRED_ARGS: -preview=bitfields
+ * TEST_OUTPUT:
+---
+fail_compilation/biterrors2.d(100): Error: variable `biterrors2.a` bit-field must be member of struct, union, or class
+fail_compilation/biterrors2.d(104): Error: bit-field `b` has zero width
+fail_compilation/biterrors2.d(105): Error: bit-field type `float` is not an integer type
+---
+*/
+
+#line 100
+int a : 2;
+
+struct S
+{
+    int b:0;
+    float c:3;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/biterrors3.d b/gcc/testsuite/gdc.test/fail_compilation/biterrors3.d
new file mode 100644 (file)
index 0000000..f9e1df2
--- /dev/null
@@ -0,0 +1,18 @@
+/* REQUIRED_ARGS: -preview=bitfields
+ * TEST_OUTPUT:
+---
+fail_compilation/biterrors3.d(103): Error: storage class not allowed for bit-field declaration
+fail_compilation/biterrors3.d(106): Error: `d` is not a valid attribute for enum members
+fail_compilation/biterrors3.d(106): Error: `:` is not a valid attribute for enum members
+fail_compilation/biterrors3.d(106): Error: `3` is not a valid attribute for enum members
+---
+*/
+
+#line 100
+
+struct S
+{
+    static int : 3;
+}
+
+enum E { d : 3 }
diff --git a/gcc/testsuite/gdc.test/fail_compilation/biterrors4.d b/gcc/testsuite/gdc.test/fail_compilation/biterrors4.d
new file mode 100644 (file)
index 0000000..0f2ca2d
--- /dev/null
@@ -0,0 +1,19 @@
+/* REQUIRED_ARGS: -preview=bitfields
+ * TEST_OUTPUT:
+---
+fail_compilation/biterrors4.d(109): Error: cannot take address of bit-field `a`
+---
+*/
+
+#line 100
+
+struct S
+{
+    int a:3;
+}
+
+void test()
+{
+    S s;
+    int* p = &s.a;
+}
index 7d50223ed6ed01644b6c1769fcfe033dbabcb14b..3874fb18ef1027210c2c52454539b6108ee5f04b 100644 (file)
@@ -1,16 +1,16 @@
 /* REQUIRED_ARGS: -o-
 TEST_OUTPUT:
 ---
-fail_compilation/commaexp.d(27): Error: Using the result of a comma expression is not allowed
-fail_compilation/commaexp.d(39): Error: Using the result of a comma expression is not allowed
-fail_compilation/commaexp.d(40): Error: Using the result of a comma expression is not allowed
-fail_compilation/commaexp.d(41): Error: Using the result of a comma expression is not allowed
-fail_compilation/commaexp.d(42): Error: Using the result of a comma expression is not allowed
-fail_compilation/commaexp.d(44): Error: Using the result of a comma expression is not allowed
-fail_compilation/commaexp.d(45): Error: Using the result of a comma expression is not allowed
-fail_compilation/commaexp.d(56): Error: Using the result of a comma expression is not allowed
-fail_compilation/commaexp.d(69): Error: Using the result of a comma expression is not allowed
-fail_compilation/commaexp.d(81): Error: Using the result of a comma expression is not allowed
+fail_compilation/commaexp.d(27): Error: using the result of a comma expression is not allowed
+fail_compilation/commaexp.d(39): Error: using the result of a comma expression is not allowed
+fail_compilation/commaexp.d(40): Error: using the result of a comma expression is not allowed
+fail_compilation/commaexp.d(41): Error: using the result of a comma expression is not allowed
+fail_compilation/commaexp.d(42): Error: using the result of a comma expression is not allowed
+fail_compilation/commaexp.d(44): Error: using the result of a comma expression is not allowed
+fail_compilation/commaexp.d(45): Error: using the result of a comma expression is not allowed
+fail_compilation/commaexp.d(56): Error: using the result of a comma expression is not allowed
+fail_compilation/commaexp.d(69): Error: using the result of a comma expression is not allowed
+fail_compilation/commaexp.d(81): Error: using the result of a comma expression is not allowed
 ---
 */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/cppvar.d b/gcc/testsuite/gdc.test/fail_compilation/cppvar.d
new file mode 100644 (file)
index 0000000..885a555
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/cppvar.d(10): Error: variable `cppvar.funcLiteral` cannot have `extern(C++)` linkage because it is `static`
+fail_compilation/cppvar.d(10):        perhaps declare it as `__gshared` instead
+fail_compilation/cppvar.d(20): Error: variable `cppvar.threadLocalVar` cannot have `extern(C++)` linkage because it is `static`
+fail_compilation/cppvar.d(20):        perhaps declare it as `__gshared` instead
+fail_compilation/cppvar.d(21): Error: variable `cppvar.staticVar` cannot have `extern(C++)` linkage because it is `static`
+fail_compilation/cppvar.d(21):        perhaps declare it as `__gshared` instead
+fail_compilation/cppvar.d(22): Error: variable `cppvar.sharedVar` cannot have `extern(C++)` linkage because it is `shared`
+fail_compilation/cppvar.d(22):        perhaps declare it as `__gshared` instead
+fail_compilation/cppvar.d(30): Error: delegate `cppvar.__lambda7` cannot return type `bool[3]` because its linkage is `extern(C++)`
+---
+*/
+#line 10
+extern(C++) bool[3] funcLiteral = () { bool[3] a; return a; };
+#line 20
+extern(C++) int threadLocalVar;
+extern(C++) static int staticVar;
+extern(C++) shared int sharedVar;
+#line 30
+extern(C++) __gshared bool[3] gfuncLiteral = () { bool[3] a; return a; };
diff --git a/gcc/testsuite/gdc.test/fail_compilation/dbitfields.d b/gcc/testsuite/gdc.test/fail_compilation/dbitfields.d
new file mode 100644 (file)
index 0000000..0dd1a0b
--- /dev/null
@@ -0,0 +1,32 @@
+/* REQUIRED_ARGS: -preview=bitfields
+ * TEST_OUTPUT:
+---
+fail_compilation/dbitfields.d(118): Error: reinterpretation through overlapped field `e` is not allowed in CTFE
+fail_compilation/dbitfields.d(121):        called from here: `testu()`
+fail_compilation/dbitfields.d(121):        while evaluating: `static assert(testu() == 1)`
+---
+ */
+
+#line 100
+
+union U
+{
+    uint a:3;
+    uint b:1;
+    ulong c:64;
+
+    int d:3;
+    int e:1;
+    long f:64;
+
+    int i;
+}
+
+int testu()
+{
+    U u;
+    u.d = 9;
+    return u.e;
+}
+
+static assert(testu() == 1);
index ed38167b4c48eaba043668b285173e6694825f73..932aa5c5769d7200a8aecc0b5b7e0acc71173ac6 100644 (file)
@@ -3,7 +3,7 @@ TEST_OUTPUT:
 ---
 fail_compilation/diag10805.d(12): Error: delimited string must end in `FOO"`
 fail_compilation/diag10805.d(14): Error: unterminated string constant starting at fail_compilation/diag10805.d(14)
-fail_compilation/diag10805.d(14): Error: Implicit string concatenation is error-prone and disallowed in D
+fail_compilation/diag10805.d(14): Error: implicit string concatenation is error-prone and disallowed in D
 fail_compilation/diag10805.d(14):        Use the explicit syntax instead (concatenating literals is `@nogc`): "" ~ ""
 fail_compilation/diag10805.d(15): Error: semicolon expected following auto declaration, not `End of File`
 ---
index 00949f1d995ffec47300d61a75fdd25695b07630..3e154979e8ce3d9e6a4b81cfe013bc62d2e10b8c 100644 (file)
@@ -24,7 +24,7 @@ fail_compilation/diag10862.d(74): Error: assignment cannot be used as a conditio
 fail_compilation/diag10862.d-mixin-77(77): Error: assignment cannot be used as a condition, perhaps `==` was meant?
 fail_compilation/diag10862.d-mixin-78(78): Error: assignment cannot be used as a condition, perhaps `==` was meant?
 fail_compilation/diag10862.d-mixin-79(79): Error: assignment cannot be used as a condition, perhaps `==` was meant?
-fail_compilation/diag10862.d-mixin-80(80): Error: Using the result of a comma expression is not allowed
+fail_compilation/diag10862.d-mixin-80(80): Error: using the result of a comma expression is not allowed
 fail_compilation/diag10862.d-mixin-80(80): Error: assignment cannot be used as a condition, perhaps `==` was meant?
 fail_compilation/diag10862.d-mixin-83(83): Error: `a + b` is not an lvalue and cannot be modified
 fail_compilation/diag10862.d-mixin-84(84): Error: undefined identifier `c`
index 4f8ea23a91d22f7810fc93ef4d46cabd757781ef..41bfe49e4845f297a1cab7dcb7f5e73064c0df87 100644 (file)
@@ -12,15 +12,15 @@ fail_compilation/dip25.d(23):        perhaps annotate the parameter with `return
 struct Data
 {
     char[256] buffer;
-    @property const(char)[] filename() const pure nothrow
+    @property const(char)[] filename() const pure nothrow @safe
     {
         return buffer[];
     }
 }
 
-ref int identity(return ref int x) { return x; }
+ref int identity(return ref int x) @safe { return x; }
 ref int fun(return int x) { return identity(x); }
-ref int fun2(ref int x) { return identity(x); }
+ref int fun2(ref int x) @safe { return identity(x); }
 
 void main()
 {
index 21a12ed0253cc99d735102d36aeb8e81c59cc808..ce81d6bfd3552e2d77fb89edc1122266f856739a 100644 (file)
@@ -8,6 +8,8 @@ fail_compilation/dtor_attributes.d(113):        generated `Strict.~this` is impu
 fail_compilation/dtor_attributes.d(111):         - HasDtor member
 fail_compilation/dtor_attributes.d(103):           impure `HasDtor.~this` is declared here
 fail_compilation/dtor_attributes.d(118): Error: `@safe` function `dtor_attributes.test1` cannot call `@system` destructor `dtor_attributes.Strict.~this`
+fail_compilation/dtor_attributes.d(113):        which calls `dtor_attributes.Strict.~this`
+fail_compilation/dtor_attributes.d(103):        which calls `dtor_attributes.HasDtor.~this`
 fail_compilation/dtor_attributes.d(113):        `dtor_attributes.Strict.~this` is declared here
 fail_compilation/dtor_attributes.d(113):        generated `Strict.~this` is @system because of the following field's destructors:
 fail_compilation/dtor_attributes.d(111):         - HasDtor member
index f6cab893bb44e222a769954c1804b2a9ad09d26a..45b23cece4dab384ceef2b7bc352117869022ff4 100644 (file)
@@ -9,6 +9,7 @@ fail_compilation/dtorfields_attributes.d(119):        generated `Strict.~this` i
 fail_compilation/dtorfields_attributes.d(115):         - HasDtor member
 fail_compilation/dtorfields_attributes.d(103):           impure `HasDtor.~this` is declared here
 fail_compilation/dtorfields_attributes.d(117): Error: `@safe` constructor `dtorfields_attributes.Strict.this` cannot call `@system` destructor `dtorfields_attributes.Strict.~this`
+fail_compilation/dtorfields_attributes.d(103):        which calls `dtorfields_attributes.HasDtor.~this`
 fail_compilation/dtorfields_attributes.d(119):        `dtorfields_attributes.Strict.~this` is declared here
 fail_compilation/dtorfields_attributes.d(119):        generated `Strict.~this` is @system because of the following field's destructors:
 fail_compilation/dtorfields_attributes.d(115):         - HasDtor member
index 38c25fbf7ae6b4afef9a36a6ab90a1fd30e5f69f..1dfcf449771b711eeba517cf21c9019247b5c20a 100644 (file)
@@ -1,11 +1,18 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/e7804_1.d(10): Error: trait `farfelu` is either invalid or not supported as type
-fail_compilation/e7804_1.d(11): Error: trait `farfelu` is either invalid or not supported in alias
+fail_compilation/e7804_1.d(14): Error: undefined identifier `Aggr`
+fail_compilation/e7804_1.d(15): Error: unrecognized trait `farfelu`
+fail_compilation/e7804_1.d(17): Error: undefined identifier `Aggr`
+fail_compilation/e7804_1.d(18): Error: unrecognized trait `farfelu`
 ---
 */
 module e7804_1;
 
+struct S {}
+
 __traits(farfelu, Aggr, "member") a;
+__traits(farfelu, S, "member") a2;
+
 alias foo = __traits(farfelu, Aggr, "member");
+alias foo2 = __traits(farfelu, S, "member");
diff --git a/gcc/testsuite/gdc.test/fail_compilation/extra-files/test23109/object.d b/gcc/testsuite/gdc.test/fail_compilation/extra-files/test23109/object.d
new file mode 100644 (file)
index 0000000..747b6e9
--- /dev/null
@@ -0,0 +1,17 @@
+module object;
+
+alias size_t = typeof(int.sizeof);
+class Object {}
+auto opEquals(Object ) { return true; }
+class TypeInfo {}
+class TypeInfo_Const {}
+bool _xopEquals() { return true; }
+
+bool __equals(T1, T2)(T1[] lhs, T2[] rhs)
+{
+    static at(R)(R[] r, size_t i) { return r.ptr[i]; }
+    foreach (u; 0 .. lhs.length)
+        if (at(lhs, u) != at(rhs, u))
+            return false;
+    return true;
+}
index 3419079f70e0cf2b3e3d6016a0e3b3ae3f6131d7..7caae59d05203d37932f16b4f45710611699cce0 100644 (file)
@@ -34,7 +34,7 @@ enum E1 : short
 /* https://issues.dlang.org/show_bug.cgi?id=14950
 TEST_OUTPUT:
 ---
-fail_compilation/fail109.d(50): Error: Comparison between different enumeration types `B` and `C`; If this behavior is intended consider using `std.conv.asOriginalType`
+fail_compilation/fail109.d(50): Error: comparison between different enumeration types `B` and `C`; If this behavior is intended consider using `std.conv.asOriginalType`
 fail_compilation/fail109.d(50): Error: enum member `fail109.B.end` initialization with `B.start+1` causes overflow for type `C`
 ---
 */
index 2ed8ebf9cc9d27ce9a60046914bba24b888febcc..bed87351bc5e1bced28ab618151fffc22b3cac1e 100644 (file)
@@ -66,8 +66,8 @@ void test12606b()   // ExpInitializer::semantic
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail12604.d(77): Error: mismatched array lengths, 4 and 3
-fail_compilation/fail12604.d(78): Error: mismatched array lengths, 4 and 3
+fail_compilation/fail12604.d(77): Error: mismatched array lengths 4 and 3 for assignment `sa1[0..4] = [1, 2, 3]`
+fail_compilation/fail12604.d(78): Error: mismatched array lengths 4 and 3 for assignment `sa1[0..4] = sa2`
 ---
 */
 void testc()
index 12a6b6e42f41e8011ca04f60fb6b4f56e12d072e..47cb65cde24fc8dee64f1ffc7568c0b67ad9c009 100644 (file)
@@ -8,11 +8,11 @@ class C { int v; }
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail13902.d(45): Error: Using the result of a comma expression is not allowed
+fail_compilation/fail13902.d(45): Error: using the result of a comma expression is not allowed
 fail_compilation/fail13902.d(32): Error: returning `& x` escapes a reference to local variable `x`
 fail_compilation/fail13902.d(33): Error: returning `&s1.v` escapes a reference to local variable `s1`
 fail_compilation/fail13902.d(38): Error: returning `& sa1` escapes a reference to local variable `sa1`
-fail_compilation/fail13902.d(39): Error: returning `&sa2[0][0]` escapes a reference to local variable `sa2`
+fail_compilation/fail13902.d(39): Error: returning `& sa2` escapes a reference to local variable `sa2`
 fail_compilation/fail13902.d(40): Error: returning `& x` escapes a reference to local variable `x`
 fail_compilation/fail13902.d(41): Error: returning `(& x+4)` escapes a reference to local variable `x`
 fail_compilation/fail13902.d(42): Error: returning `& x + cast(long)x * 4L` escapes a reference to local variable `x`
@@ -53,11 +53,11 @@ int* testEscape1()
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail13902.d(88): Error: Using the result of a comma expression is not allowed
+fail_compilation/fail13902.d(88): Error: using the result of a comma expression is not allowed
 fail_compilation/fail13902.d(75): Error: returning `& x` escapes a reference to parameter `x`
 fail_compilation/fail13902.d(76): Error: returning `&s1.v` escapes a reference to parameter `s1`
 fail_compilation/fail13902.d(81): Error: returning `& sa1` escapes a reference to parameter `sa1`
-fail_compilation/fail13902.d(82): Error: returning `&sa2[0][0]` escapes a reference to parameter `sa2`
+fail_compilation/fail13902.d(82): Error: returning `& sa2` escapes a reference to parameter `sa2`
 fail_compilation/fail13902.d(83): Error: returning `& x` escapes a reference to parameter `x`
 fail_compilation/fail13902.d(84): Error: returning `(& x+4)` escapes a reference to parameter `x`
 fail_compilation/fail13902.d(85): Error: returning `& x + cast(long)x * 4L` escapes a reference to parameter `x`
@@ -98,7 +98,7 @@ int* testEscape2(
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail13902.d(123): Error: Using the result of a comma expression is not allowed
+fail_compilation/fail13902.d(123): Error: using the result of a comma expression is not allowed
 ---
 */
 int* testEscape3(
index dc480cffb5668295541eb48701f6fe05df729ec4..9d0b96f81d9b949ab931905c630ab455d8569ac0 100644 (file)
@@ -2,7 +2,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail16001.d(10): Deprecation: Using `(args) => { ... }` to create a delegate that returns a delegate is error-prone.
+fail_compilation/fail16001.d(10): Deprecation: using `(args) => { ... }` to create a delegate that returns a delegate is error-prone.
 fail_compilation/fail16001.d(10):        Use `(args) { ... }` for a multi-statement function literal or use `(args) => () { }` if you intended for the lambda to return a delegate.
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail16575.d b/gcc/testsuite/gdc.test/fail_compilation/fail16575.d
new file mode 100644 (file)
index 0000000..7f66724
--- /dev/null
@@ -0,0 +1,65 @@
+// https://issues.dlang.org/show_bug.cgi?id=16575
+/*
+REQUIRED_ARGS: -m64
+TEST_OUTPUT:
+---
+fail_compilation/fail16575.d(10): Error: function `fail16575.immNull` cannot have parameter of type `immutable(typeof(null))*` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(11): Error: function `fail16575.shaNull` cannot have parameter of type `shared(typeof(null))*` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(20): Error: function `fail16575.immNoReturn` cannot have parameter of type `immutable(noreturn)*` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(21): Error: function `fail16575.shaNoReturn` cannot have parameter of type `shared(noreturn)*` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(30): Error: function `fail16575.immBasic` cannot have parameter of type `immutable(int)*` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(31): Error: function `fail16575.shaBasic` cannot have parameter of type `shared(int)*` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(40): Error: function `fail16575.immVector` cannot have parameter of type `immutable(__vector(long[2]))*` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(41): Error: function `fail16575.shaVector` cannot have parameter of type `shared(__vector(long[2]))*` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(50): Error: function `fail16575.immSArray` cannot have parameter of type `immutable(long[2])` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(50):        perhaps use a `long*` type instead
+fail_compilation/fail16575.d(51): Error: function `fail16575.shaSArray` cannot have parameter of type `shared(long[2])` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(51):        perhaps use a `long*` type instead
+fail_compilation/fail16575.d(60): Error: function `fail16575.immPointer` cannot have parameter of type `immutable(int*)` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(61): Error: function `fail16575.shaPointer` cannot have parameter of type `shared(int*)` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(71): Error: function `fail16575.immStruct` cannot have parameter of type `immutable(SPP)*` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(72): Error: function `fail16575.shaStruct` cannot have parameter of type `shared(SPP)*` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(81): Error: function `fail16575.immClass` cannot have parameter of type `immutable(CPP)` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(82): Error: function `fail16575.shaClass` cannot have parameter of type `shared(CPP)` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(91): Error: function `fail16575.immEnum` cannot have parameter of type `immutable(EPP)*` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(92): Error: function `fail16575.shaEnum` cannot have parameter of type `shared(EPP)*` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(100): Error: function `fail16575.typeDArray` cannot have parameter of type `int[]` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(101): Error: function `fail16575.typeAArray` cannot have parameter of type `int[int]` because its linkage is `extern(C++)`
+fail_compilation/fail16575.d(102): Error: function `fail16575.typeDelegate` cannot have parameter of type `extern (C++) int delegate()` because its linkage is `extern(C++)`
+---
+*/
+
+#line 10
+extern(C++) void immNull(immutable(typeof(null))* a) {}
+extern(C++) void shaNull(shared(typeof(null))* a) {}
+#line 20
+extern(C++) void immNoReturn(immutable(typeof(*null))* a) {}
+extern(C++) void shaNoReturn(shared(typeof(*null))* a) {}
+#line 30
+extern(C++) void immBasic(immutable(int)* a) {}
+extern(C++) void shaBasic(shared(int)* a) {}
+#line 40
+extern(C++) void immVector(immutable(__vector(long[2]))* a) {}
+extern(C++) void shaVector(shared(__vector(long[2]))* a) {}
+#line 50
+extern(C++) void immSArray(immutable(long[2]) a) {}
+extern(C++) void shaSArray(shared(long[2]) a) {}
+#line 60
+extern(C++) void immPointer(immutable(int*) a) {}
+extern(C++) void shaPointer(shared(int*) a) {}
+#line 70
+extern(C++) struct SPP {}
+extern(C++) void immStruct(immutable(SPP)* a) {}
+extern(C++) void shaStruct(shared(SPP)* a) {}
+#line 80
+extern(C++) class CPP {}
+extern(C++) void immClass(immutable CPP a) {}
+extern(C++) void shaClass(shared CPP a) {}
+#line 90
+extern(C++) enum EPP {a}
+extern(C++) void immEnum(immutable(EPP)* a) {}
+extern(C++) void shaEnum(shared(EPP)* a) {}
+# line 100
+extern(C++) void typeDArray(int[] a) {}
+extern(C++) void typeAArray(int[int] a) {}
+extern(C++) void typeDelegate(int delegate() a) {}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail16772.d b/gcc/testsuite/gdc.test/fail_compilation/fail16772.d
new file mode 100644 (file)
index 0000000..e77951d
--- /dev/null
@@ -0,0 +1,7 @@
+// https://issues.dlang.org/show_bug.cgi?id=16772
+/* TEST_OUTPUT:
+---
+fail_compilation/fail16772.d(7): Error: function `fail16772.ice16772` cannot return type `ubyte[]` because its linkage is `extern(C++)`
+---
+*/
+extern(C++) ubyte[] ice16772() { return []; }
index 55c3bd89ff9c3dfad92d1af2e583fffe9bd52e13..2c7d93fe4e064105d9bcab92a282bd35ccfe9753 100644 (file)
@@ -2,7 +2,7 @@
 TEST_OUTPUT:
 ---
 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): 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)" ~ ";\n    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
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail19759.d b/gcc/testsuite/gdc.test/fail_compilation/fail19759.d
new file mode 100644 (file)
index 0000000..cdb65ae
--- /dev/null
@@ -0,0 +1,8 @@
+// https://issues.dlang.org/show_bug.cgi?id=19759
+/* TEST_OUTPUT:
+---
+fail_compilation/fail19759.d(8): Error: function `fail19759.fail19759` cannot have parameter of type `float[4]` because its linkage is `extern(C++)`
+fail_compilation/fail19759.d(8):        perhaps use a `float*` type instead
+---
+*/
+extern(C++) bool fail19759(float[4] col);
index f4a4d7606533d66cbd5833d81f7a823b59bb79d7..62f3dc4310015e5a9dbaf0b5fcfa239cc4639843 100644 (file)
@@ -1,7 +1,8 @@
 /* REQUIRED_ARGS: -preview=dip1000
  * TEST_OUTPUT:
 ---
-fail_compilation/fail19881.d(12): Error: address of local variable `local` assigned to return scope `input`
+fail_compilation/fail19881.d(13): Error: address of local variable `local` assigned to return scope `input`
+fail_compilation/fail19881.d(13): Error: address of variable `local` assigned to `input` with longer lifetime
 ---
  */
 
index 7a43232658d883cdf0ebaec2ba7e4075729a9240..54e36fcfb7cdadc2dd04c7a03978126d08243277 100644 (file)
@@ -1,12 +1,9 @@
 /* REQUIRED_ARGS: -preview=dip1000
 TEST_OUTPUT:
 ---
-fail_compilation/fail20691.d(106): Error: cannot take address of `scope` local `sa` in `@safe` function `bar`
-fail_compilation/fail20691.d(106): Error: cannot cast expression `sa` of type `char[][2]` to `char[][]`
-fail_compilation/fail20691.d(107): Error: cannot take address of `scope` local `sa` in `@safe` function `bar`
-fail_compilation/fail20691.d(107): Error: cannot cast expression `sa` of type `char[][2]` to `char[][]`
-fail_compilation/fail20691.d(108): Error: cannot take address of `scope` local `sa` in `@safe` function `bar`
-fail_compilation/fail20691.d(108): Error: cannot cast expression `sa` of type `char[][2]` to `char[][]`
+fail_compilation/fail20691.d(106): Error: cannot take address of `scope` variable `sa` since `scope` applies to first indirection only
+fail_compilation/fail20691.d(107): Error: cannot take address of `scope` variable `sa` since `scope` applies to first indirection only
+fail_compilation/fail20691.d(108): Error: cannot take address of `scope` variable `sa` since `scope` applies to first indirection only
 ---
 */
 
index 2ca826e70aba0e5642c887055b7560d9158184ed..d12b387a58711291425d1979e9251fa24dca0570 100644 (file)
@@ -3,10 +3,10 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail21092.d(19): Error: Using the result of a comma expression is not allowed
+fail_compilation/fail21092.d(19): Error: using the result of a comma expression is not allowed
 fail_compilation/fail21092.d(19): Error: using `*` on an array is no longer supported; use `*(T , U).ptr` instead
 fail_compilation/fail21092.d(19): Error: `*(T , cast(real*)U)` has no effect
-fail_compilation/fail21092.d(26): Error: Using the result of a comma expression is not allowed
+fail_compilation/fail21092.d(26): Error: using the result of a comma expression is not allowed
 fail_compilation/fail21092.d(26): Error: using `*` on an array is no longer supported; use `*(w , SmallStirlingCoeffs).ptr` instead
 fail_compilation/fail21092.d(26): Error: `*(w , cast(real*)SmallStirlingCoeffs)` has no effect
 ---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail21206.d b/gcc/testsuite/gdc.test/fail_compilation/fail21206.d
new file mode 100644 (file)
index 0000000..c3d648e
--- /dev/null
@@ -0,0 +1,13 @@
+// https://issues.dlang.org/show_bug.cgi?id=21206
+/* TEST_OUTPUT:
+---
+fail_compilation/fail21206.d(9): Error: function `fail21206.Obj.toString` cannot return type `string` because its linkage is `extern(C++)`
+---
+*/
+extern(C++) struct Obj
+{
+    string toString()
+    {
+        return "ret";
+    }
+}
index dbdedb3873ff4dbf023a0ba400916789d63197d8..69cdf1ada9afe0060ddece30b9ea908aa61cab39 100644 (file)
@@ -5,8 +5,8 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail21275.d(18): Deprecation: Function `imports.fail21275a.Foo.x` of type `ref int() return` is not accessible from module `fail21275`
-fail_compilation/fail21275.d(21): Deprecation: Function `imports.fail21275a.Bar.x` of type `int(int)` is not accessible from module `fail21275`
+fail_compilation/fail21275.d(18): Deprecation: function `imports.fail21275a.Foo.x` of type `ref int() return` is not accessible from module `fail21275`
+fail_compilation/fail21275.d(21): Deprecation: function `imports.fail21275a.Bar.x` of type `int(int)` is not accessible from module `fail21275`
 ---
 */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail21314.d b/gcc/testsuite/gdc.test/fail_compilation/fail21314.d
new file mode 100644 (file)
index 0000000..78e52ce
--- /dev/null
@@ -0,0 +1,11 @@
+// https://issues.dlang.org/show_bug.cgi?id=21314
+/* TEST_OUTPUT:
+---
+fail_compilation/fail21314.d(10): Error: variable `fail21314.C21314.c21314` cannot have `extern(C++)` linkage because it is `static`
+fail_compilation/fail21314.d(10):        perhaps declare it as `__gshared` instead
+---
+*/
+extern(C++) class C21314
+{
+    static C21314[] c21314;
+}
index 687a727263447b57f064235c10549c3ba71c7c7f..0df31d7de3f3ad796bfaa1e35df6f1859d5eeca6 100644 (file)
@@ -14,7 +14,7 @@ struct S
     int* y;
 }
 
-int* test(ref return scope S s)
+int* test(ref return scope S s) @safe
 {
     return &s.x;
 }
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail23108a.d b/gcc/testsuite/gdc.test/fail_compilation/fail23108a.d
new file mode 100644 (file)
index 0000000..a974871
--- /dev/null
@@ -0,0 +1,16 @@
+// https://issues.dlang.org/show_bug.cgi?id=23108
+/* TEST_OUTPUT:
+---
+fail_compilation/fail23108a.d(9): Error: undefined identifier `_xopEquals` in module `object`
+---
+*/
+module object;
+
+struct Interface
+{
+    void[] vtbl;
+}
+
+class TypeInfo
+{
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail23108b.d b/gcc/testsuite/gdc.test/fail_compilation/fail23108b.d
new file mode 100644 (file)
index 0000000..10eae37
--- /dev/null
@@ -0,0 +1,18 @@
+// https://issues.dlang.org/show_bug.cgi?id=23108
+/* TEST_OUTPUT:
+---
+fail_compilation/fail23108b.d(10): Error: undefined identifier `_xopEquals` in module `object`
+fail_compilation/fail23108b.d(10): Error: undefined identifier `_xopCmp` in module `object`
+---
+*/
+module object;
+
+struct Interface
+{
+    void[] vtbl;
+    int opCmp() { return 0; }
+}
+
+class TypeInfo
+{
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail23109.d b/gcc/testsuite/gdc.test/fail_compilation/fail23109.d
new file mode 100644 (file)
index 0000000..91b4e79
--- /dev/null
@@ -0,0 +1,12 @@
+// https://issues.dlang.org/show_bug.cgi?id=23109
+/*
+EXTRA_FILES: imports/test23109a.d imports/test23109b.d imports/test23109c.d
+EXTRA_SOURCES: extra-files/test23109/object.d
+TEST_OUTPUT:
+---
+Error: no property `getHash` for type `object.TypeInfo_Const`
+Error: no property `getHash` for type `object.TypeInfo_Const`
+fail_compilation/imports/test23109a.d(10): Error: template instance `imports.test23109a.Array!(Ensure)` error instantiating
+---
+*/
+import imports.test23109a;
index 6b4edd5b6290cb6c63509ef8dd02ebc949509ea2..d2d277f50658b864c343338f10ffb7d3c807678d 100644 (file)
@@ -3,8 +3,8 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/fail3703.d(18): Error: mismatched array lengths, 2 and 1
-fail_compilation/fail3703.d(20): Error: mismatched array lengths, 2 and 1
+fail_compilation/fail3703.d(18): Error: mismatched array lengths 2 and 1 for assignment `b[] = a`
+fail_compilation/fail3703.d(20): Error: mismatched array lengths 2 and 1 for assignment `b[] = a`
 fail_compilation/fail3703.d(22): Error: mismatched array lengths, 3 and 2
 fail_compilation/fail3703.d(23): Error: mismatched array lengths, 2 and 3
 fail_compilation/fail3703.d(25): Error: mismatched array lengths, 3 and 2
index 07c3766d4904cfa1d2c0cc12c308ca0c77fb2ca2..153e90b034a3afeca86d8a099860ea2b6d10de41 100644 (file)
@@ -2,39 +2,40 @@
 REQUIRED_ARGS:
 TEST_OUTPUT:
 ---
-fail_compilation/fail_scope.d(29): Deprecation: scope variable `da` may not be returned
-fail_compilation/fail_scope.d(31): Deprecation: scope variable `o` may not be returned
-fail_compilation/fail_scope.d(32): Deprecation: scope variable `dg` may not be returned
-fail_compilation/fail_scope.d(34): Deprecation: scope variable `da` may not be returned
-fail_compilation/fail_scope.d(36): Deprecation: scope variable `o` may not be returned
-fail_compilation/fail_scope.d(37): Deprecation: scope variable `dg` may not be returned
-fail_compilation/fail_scope.d(39): Deprecation: scope variable `p` may not be returned
-fail_compilation/fail_scope.d(44): Error: returning `cast(char[])string` escapes a reference to local variable `string`
-fail_compilation/fail_scope.d(62): Error: returning `s.bar()` escapes a reference to local variable `s`
-fail_compilation/fail_scope.d(73): Error: `fail_scope.foo8` called with argument types `(int)` matches both:
-fail_compilation/fail_scope.d(67):     `fail_scope.foo8(ref int x)`
+fail_compilation/fail_scope.d(40): Deprecation: scope variable `p` may not be returned
+fail_compilation/fail_scope.d(45): Error: returning `cast(char[])string` escapes a reference to local variable `string`
+fail_compilation/fail_scope.d(63): Error: returning `s.bar()` escapes a reference to local variable `s`
+fail_compilation/fail_scope.d(74): Error: `fail_scope.foo8` called with argument types `(int)` matches both:
+fail_compilation/fail_scope.d(68):     `fail_scope.foo8(ref int x)`
 and:
-fail_compilation/fail_scope.d(68):     `fail_scope.foo8(return ref int x)`
-fail_compilation/fail_scope.d(81): Error: returning `& string` escapes a reference to local variable `string`
-fail_compilation/fail_scope.d(91): Error: returning `cast(int[])a` escapes a reference to local variable `a`
-fail_compilation/fail_scope.d(99): Error: returning `cast(int[])a` escapes a reference to local variable `a`
-fail_compilation/fail_scope.d(107): Deprecation: escaping reference to outer local variable `x`
-fail_compilation/fail_scope.d(126): Error: returning `s.bar()` escapes a reference to local variable `s`
-fail_compilation/fail_scope.d(136): Error: returning `foo16226(i)` escapes a reference to local variable `i`
+fail_compilation/fail_scope.d(69):     `fail_scope.foo8(return ref int x)`
+fail_compilation/fail_scope.d(82): Error: returning `& string` escapes a reference to local variable `string`
+fail_compilation/fail_scope.d(92): Error: returning `cast(int[])a` escapes a reference to local variable `a`
+fail_compilation/fail_scope.d(100): Error: returning `cast(int[])a` escapes a reference to local variable `a`
+fail_compilation/fail_scope.d(108): Deprecation: escaping reference to outer local variable `x`
+fail_compilation/fail_scope.d(127): Error: returning `s.bar()` escapes a reference to local variable `s`
+fail_compilation/fail_scope.d(137): Error: returning `foo16226(i)` escapes a reference to local variable `i`
 ---
+//fail_compilation/fail_scope.d(30): Error: scope variable `da` may not be returned
+//fail_compilation/fail_scope.d(32): Error: scope variable `o` may not be returned
+//fail_compilation/fail_scope.d(33): Error: scope variable `dg` may not be returned
+//fail_compilation/fail_scope.d(35): Error: scope variable `da` may not be returned
+//fail_compilation/fail_scope.d(37): Error: scope variable `o` may not be returned
+//fail_compilation/fail_scope.d(38): Error: scope variable `dg` may not be returned
+//fail_compilation/fail_scope.d(40): Error: scope variable `p` may not be returned
 */
 
 alias int delegate() dg_t;
 
-int[]  checkEscapeScope1(scope int[]  da) @safe { return da; }
-int[3] checkEscapeScope2(scope int[3] sa) @safe { return sa; }
-Object checkEscapeScope3(scope Object o)  @safe { return o;  }
-dg_t   checkEscapeScope4(scope dg_t   dg) @safe { return dg; }
+int[]  checkEscapeScope1(scope int[]  da) { return da; }
+int[3] checkEscapeScope2(scope int[3] sa) { return sa; }
+Object checkEscapeScope3(scope Object o)  { return o;  }
+dg_t   checkEscapeScope4(scope dg_t   dg) { return dg; }
 
-int[]  checkEscapeScope1() @safe { scope int[]  da = [];           return da; }
-int[3] checkEscapeScope2() @safe { scope int[3] sa = [1,2,3];      return sa; }
-Object checkEscapeScope3() @safe { scope Object  o = new Object;   return o;  }   // same with fail7294.d
-dg_t   checkEscapeScope4() @safe { scope dg_t   dg = () => 1;      return dg; }
+int[]  checkEscapeScope1() { scope int[]  da = [];           return da; }
+int[3] checkEscapeScope2() { scope int[3] sa = [1,2,3];      return sa; }
+Object checkEscapeScope3() { scope Object  o = new Object;   return o;  }   // same with fail7294.d
+dg_t   checkEscapeScope4() { scope dg_t   dg = () => 1;      return dg; }
 
 int* test(scope int* p) @safe { return p; }
 
index 45b18e0de5ab9fafdbe80b298075f12c8575c8ee..b39548ddb06ceeb6ab9214ed4680dd9bebfa1040 100644 (file)
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/ice10949.d(12): Error: Using the result of a comma expression is not allowed
+fail_compilation/ice10949.d(12): Error: using the result of a comma expression is not allowed
 fail_compilation/ice10949.d(12): Error: array index 3 is out of bounds `[5, 5][0 .. 2]`
 fail_compilation/ice10949.d(12): Error: array index 17 is out of bounds `[2, 3][0 .. 2]`
 fail_compilation/ice10949.d(12):        while evaluating: `static assert((((([5, 5][3] + global - global) * global / global % global >> global & global | global) ^ global) == 9 , [2, 3][17]) || [3, 3, 3][9] is 4 && [[1, 2, 3]][4].length)`
index 9f602a531563a488f644c79e4a3db24fa59fffec..d466a3000b332d7812b8e070b2d0126063f7dd67 100644 (file)
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/ice14844.d(21): Error: In expression `__traits(allMembers, opDispatch)` template `opDispatch(string name)` has no members
+fail_compilation/ice14844.d(21): Error: in expression `__traits(allMembers, opDispatch)` template `opDispatch(string name)` has no members
 fail_compilation/ice14844.d(21):        `opDispatch(string name)` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation
 ---
 */
index 4616f99212a36084be272e2b1ed2863c103fcdec..686e700cae9b13878e2271c6aba38341173ab64b 100644 (file)
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/ice22377.d(8): Error: Internal Compiler Error: type `string` cannot be mapped to C++
+fail_compilation/ice22377.d(8): Error: function `ice22377.foo` cannot have parameter of type `string` because its linkage is `extern(C++)`
 ---
 */
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice23097.d b/gcc/testsuite/gdc.test/fail_compilation/ice23097.d
new file mode 100644 (file)
index 0000000..4fd1f61
--- /dev/null
@@ -0,0 +1,28 @@
+/* https://issues.dlang.org/show_bug.cgi?id=23097
+TEST_OUTPUT:
+---
+fail_compilation/ice23097.d(12): Error: undefined identifier `ICE`
+fail_compilation/ice23097.d(27): Error: template instance `ice23097.ice23097!(S23097)` error instantiating
+fail_compilation/ice23097.d(27): Error: function `ice23097.ice23097!(S23097).ice23097(S23097 _param_0)` is not callable using argument types `(S23097)`
+fail_compilation/ice23097.d(27):        generating a copy constructor for `struct S23097` failed, therefore instances of it are uncopyable
+---
+*/
+auto ice23097(I)(I)
+{
+    ICE;
+}
+
+struct Cpctor23097
+{
+    this(ref typeof(this)) { }
+}
+
+struct S23097
+{
+    Cpctor23097 cpctor;
+}
+
+auto fail23097(S23097 s)
+{
+    s.ice23097;
+}
index d7086b42c36eeefa7ca9b71d10737ddab7be6c8f..8ba1cbf0737c7456eb1b78f53d139cb456587350 100644 (file)
@@ -1,11 +1,11 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/ice9254a.d(15): Error: Using the result of a comma expression is not allowed
-fail_compilation/ice9254a.d(15): Error: Using the result of a comma expression is not allowed
-fail_compilation/ice9254a.d(15): Error: Using the result of a comma expression is not allowed
-fail_compilation/ice9254a.d(15): Error: Using the result of a comma expression is not allowed
-fail_compilation/ice9254a.d(15): Error: Using the result of a comma expression is not allowed
+fail_compilation/ice9254a.d(15): Error: using the result of a comma expression is not allowed
+fail_compilation/ice9254a.d(15): Error: using the result of a comma expression is not allowed
+fail_compilation/ice9254a.d(15): Error: using the result of a comma expression is not allowed
+fail_compilation/ice9254a.d(15): Error: using the result of a comma expression is not allowed
+fail_compilation/ice9254a.d(15): Error: using the result of a comma expression is not allowed
 fail_compilation/ice9254a.d(15): Error: invalid `foreach` aggregate `false` of type `bool`
 ---
 */
index 5484abdee4b479ab353f69b781c2071a1f8de90b..04f28fd3997e22c2c7d3bd6bed4547d39ca9ed89 100644 (file)
@@ -1,11 +1,11 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/ice9254b.d(17): Error: Using the result of a comma expression is not allowed
-fail_compilation/ice9254b.d(17): Error: Using the result of a comma expression is not allowed
-fail_compilation/ice9254b.d(17): Error: Using the result of a comma expression is not allowed
-fail_compilation/ice9254b.d(17): Error: Using the result of a comma expression is not allowed
-fail_compilation/ice9254b.d(17): Error: Using the result of a comma expression is not allowed
+fail_compilation/ice9254b.d(17): Error: using the result of a comma expression is not allowed
+fail_compilation/ice9254b.d(17): Error: using the result of a comma expression is not allowed
+fail_compilation/ice9254b.d(17): Error: using the result of a comma expression is not allowed
+fail_compilation/ice9254b.d(17): Error: using the result of a comma expression is not allowed
+fail_compilation/ice9254b.d(17): Error: using the result of a comma expression is not allowed
 fail_compilation/ice9254b.d(17): Error: invalid `foreach` aggregate `false` of type `bool`
 ---
 */
index 23eeecc13e5707bcc626c56ab80e2a1e9d5f7da5..acecc8d178c61f1619b5a0689150d4c72e57b450 100644 (file)
@@ -1,11 +1,11 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/ice9254c.d(15): Error: Using the result of a comma expression is not allowed
-fail_compilation/ice9254c.d(15): Error: Using the result of a comma expression is not allowed
-fail_compilation/ice9254c.d(15): Error: Using the result of a comma expression is not allowed
-fail_compilation/ice9254c.d(15): Error: Using the result of a comma expression is not allowed
-fail_compilation/ice9254c.d(15): Error: Using the result of a comma expression is not allowed
+fail_compilation/ice9254c.d(15): Error: using the result of a comma expression is not allowed
+fail_compilation/ice9254c.d(15): Error: using the result of a comma expression is not allowed
+fail_compilation/ice9254c.d(15): Error: using the result of a comma expression is not allowed
+fail_compilation/ice9254c.d(15): Error: using the result of a comma expression is not allowed
+fail_compilation/ice9254c.d(15): Error: using the result of a comma expression is not allowed
 fail_compilation/ice9254c.d(15): Error: invalid `foreach` aggregate `false` of type `bool`
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/test23109a.d b/gcc/testsuite/gdc.test/fail_compilation/imports/test23109a.d
new file mode 100644 (file)
index 0000000..5a11d91
--- /dev/null
@@ -0,0 +1,10 @@
+module imports.test23109a;
+import imports.test23109c;
+import imports.test23109b;
+struct Array(T)
+{
+    T[] data;
+    enum SMALLARRAYCAP = 1;
+    T[SMALLARRAYCAP] smallarray;
+}
+alias Ensures = Array!Ensure;
diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/test23109b.d b/gcc/testsuite/gdc.test/fail_compilation/imports/test23109b.d
new file mode 100644 (file)
index 0000000..38680d3
--- /dev/null
@@ -0,0 +1,10 @@
+module imports.test23109b;
+import imports.test23109a;
+import imports.test23109c;
+struct Ensure
+{
+    Statement ensure;
+    Ensures* arraySyntaxCopy()
+    {
+    }
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/test23109c.d b/gcc/testsuite/gdc.test/fail_compilation/imports/test23109c.d
new file mode 100644 (file)
index 0000000..c6faf5c
--- /dev/null
@@ -0,0 +1,3 @@
+module imports.test23109c;
+import imports.test23109b;
+class Statement {}
index d17cee8358412e34eacd1d7d1989c8300d130287..12ae60bcb789cc829a4f7f88f61488605257e7a3 100644 (file)
@@ -2,9 +2,9 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/issue3827.d(14): Error: Implicit string concatenation is error-prone and disallowed in D
+fail_compilation/issue3827.d(14): Error: implicit string concatenation is error-prone and disallowed in D
 fail_compilation/issue3827.d(14):        Use the explicit syntax instead (concatenating literals is `@nogc`): "Hello" ~ "World"
-fail_compilation/issue3827.d(15): Error: Implicit string concatenation is error-prone and disallowed in D
+fail_compilation/issue3827.d(15): Error: implicit string concatenation is error-prone and disallowed in D
 fail_compilation/issue3827.d(15):        Use the explicit syntax instead (concatenating literals is `@nogc`): "A" ~ "B"
 ---
 */
index 5a8af977227b242f31d38bd41c524447e2cd64f4..eb385cbdc70d3ccf8babd2a93d3be881e41b1061 100644 (file)
@@ -4,8 +4,8 @@ REQUIRED_ARGS: -c
 EXTRA_SOURCES: extra-files/minimal/object.d
 TEST_OUTPUT:
 ---
-fail_compilation/no_Throwable.d(14): Error: Cannot use `throw` statements because `object.Throwable` was not declared
-fail_compilation/no_Throwable.d(19): Error: Cannot use try-catch statements because `object.Throwable` was not declared
+fail_compilation/no_Throwable.d(14): Error: cannot use `throw` statements because `object.Throwable` was not declared
+fail_compilation/no_Throwable.d(19): Error: cannot use try-catch statements because `object.Throwable` was not declared
 ---
 */
 
index 64db4c811962eeb83834d2820f0a5a7a26cc743a..27d566362bdb7f18e7a4c66f836423243402ce99 100644 (file)
@@ -85,7 +85,7 @@ struct HTTP
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/retscope.d(96): Error: reference to local variable `sa` assigned to non-scope parameter `a` calling retscope.bar8
+fail_compilation/retscope.d(96): Error: reference to local variable `sa` assigned to non-scope parameter `a`
 ---
 */
 // https://issues.dlang.org/show_bug.cgi?id=8838
@@ -234,16 +234,16 @@ void* funretscope(scope dg_t ptr) @safe
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `__lambda2` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() @safe`
-fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `__lambda2` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() @safe`
-fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `__lambda4` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() @safe`
-fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `__lambda4` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() @safe`
+fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `__lambda2` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe`
+fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `__lambda2` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe`
+fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `__lambda4` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe`
+fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `__lambda4` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe`
 ---
 */
 
 void escape4() @safe
 {
-    alias FunDG = void* delegate () @safe;
+    alias FunDG = void* delegate () scope @safe;
     int x = 42;
     scope FunDG f = () return { return &x; };
     scope FunDG g = ()        { return &x; };
@@ -254,7 +254,7 @@ void escape4() @safe
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/retscope.d(266): Error: cannot take address of `scope` local `p` in `@safe` function `escape5`
+fail_compilation/retscope.d(266): Error: cannot take address of `scope` variable `p` since `scope` applies to first indirection only
 ---
 */
 
@@ -331,7 +331,7 @@ int* bar10( scope int** ptr ) @safe
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/retscope.d(342): Error: cannot take address of `scope` local `aa` in `@safe` function `escape11`
+fail_compilation/retscope.d(342): Error: cannot take address of `scope` variable `aa` since `scope` applies to first indirection only
 ---
 */
 
@@ -403,7 +403,7 @@ class Foo13
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/retscope.d(1205): Error: scope variable `f14` assigned to non-scope parameter `this` calling retscope.Foo14.foo
+fail_compilation/retscope.d(1205): Error: scope variable `f14` assigned to non-scope parameter `this`
 ---
 */
 
@@ -454,7 +454,7 @@ fail_compilation/retscope.d(1311): Error: scope variable `u2` assigned to `ek` w
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/retscope.d(1405): Error: reference to local variable `buf` assigned to non-scope parameter `__anonymous_param` calling retscope.myprintf
+fail_compilation/retscope.d(1405): Error: reference to local variable `buf` assigned to non-scope parameter `__anonymous_param`
 ---
 */
 
index 4f1e3249e00ab59e871383c09fa264424dbbf64d..17d2182b4544a7ecd6ca7f528da4353f89969741 100644 (file)
@@ -86,8 +86,8 @@ fail_compilation/retscope2.d(504): Error: scope variable `c` may not be returned
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/retscope2.d(604): Error: scope variable `_param_0` assigned to non-scope parameter `__anonymous_param` calling retscope2.foo600
-fail_compilation/retscope2.d(604): Error: scope variable `_param_1` assigned to non-scope parameter `__anonymous_param` calling retscope2.foo600
+fail_compilation/retscope2.d(604): Error: scope variable `_param_0` assigned to non-scope parameter `__anonymous_param`
+fail_compilation/retscope2.d(604): Error: scope variable `_param_1` assigned to non-scope parameter `__anonymous_param`
 fail_compilation/retscope2.d(614): Error: template instance `retscope2.test600!(int*, int*)` error instantiating
 ---
 */
@@ -156,7 +156,7 @@ fail_compilation/retscope2.d(804): Error: scope variable `e` may not be thrown
 
 #line 800
 
-void foo800()
+void foo800() @safe
 {
     scope Exception e;
     throw e;
index 6d5807b641a27ba06e460c74b237d611b814f917..b9a85aeddc1cf9edb33e571f51d93898bb1fe009 100644 (file)
@@ -76,9 +76,9 @@ void foo() @safe
 /* TEST_OUTPUT:
 ---
 fail_compilation/retscope6.d(8016): Error: address of variable `i` assigned to `p` with longer lifetime
-fail_compilation/retscope6.d(8031): Error: reference to local variable `i` assigned to non-scope parameter `p` calling retscope6.betty!().betty
-fail_compilation/retscope6.d(8031): Error: reference to local variable `j` assigned to non-scope parameter `q` calling retscope6.betty!().betty
-fail_compilation/retscope6.d(8048): Error: reference to local variable `j` assigned to non-scope parameter `q` calling retscope6.archie!().archie
+fail_compilation/retscope6.d(8031): Error: reference to local variable `i` assigned to non-scope parameter `p`
+fail_compilation/retscope6.d(8031): Error: reference to local variable `j` assigned to non-scope parameter `q`
+fail_compilation/retscope6.d(8048): Error: reference to local variable `j` assigned to non-scope parameter `q`
 ---
 */
 
@@ -172,7 +172,7 @@ T9 testfred()
 
 /* TEST_OUTPUT:
 ---
-fail_compilation/retscope6.d(10003): Error: scope variable `values` assigned to non-scope parameter `values` calling retscope6.escape
+fail_compilation/retscope6.d(10003): Error: scope variable `values` assigned to non-scope parameter `values`
 ---
 */
 
@@ -234,7 +234,7 @@ const(int)* f_c_20150() @safe nothrow
 
 /* TEST_OUTPUT:
 ---
-fail_compilation/retscope6.d(13010): Error: reference to local variable `str` assigned to non-scope parameter `x` calling retscope6.f_throw
+fail_compilation/retscope6.d(13010): Error: reference to local variable `str` assigned to non-scope parameter `x`
 ---
 */
 
@@ -254,7 +254,7 @@ void escape_throw_20150() @safe
 
 /* TEST_OUTPUT:
 ---
-fail_compilation/retscope6.d(14019): Error: scope variable `scopePtr` assigned to non-scope parameter `x` calling retscope6.noInfer23021
+fail_compilation/retscope6.d(14019): Error: scope variable `scopePtr` assigned to non-scope parameter `x`
 fail_compilation/retscope6.d(14022): Error: scope variable `scopePtr` may not be returned
 ---
 */
diff --git a/gcc/testsuite/gdc.test/fail_compilation/safe_gshared.d b/gcc/testsuite/gdc.test/fail_compilation/safe_gshared.d
new file mode 100644 (file)
index 0000000..ea0775c
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/safe_gshared.d(13): Error: `@safe` function `f` cannot access `__gshared` data `x`
+fail_compilation/safe_gshared.d(14): Error: `@safe` function `f` cannot access `__gshared` data `x`
+---
+*/
+
+__gshared int x;
+
+@safe int f()
+{
+    x++;
+    return x;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/safe_pointer_index.d b/gcc/testsuite/gdc.test/fail_compilation/safe_pointer_index.d
new file mode 100644 (file)
index 0000000..4b107db
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/safe_pointer_index.d(11): Error: `@safe` function `f` cannot index pointer `x`
+---
+*/
+
+@safe void f(int* x)
+{
+    int y = x[0]; // allowed, same as *x
+    int z = x[1];
+}
index c45d76aec1fc3dc0e390f97e7fcfad59b134dab8..f4e2cac93ccab10cfbd6eb7768af006bc2957be3 100644 (file)
@@ -2,7 +2,7 @@
 TEST_OUTPUT:
 ---
 fail_compilation/test13536.d(23): Error: field `U.sysDg` cannot access pointers in `@safe` code that overlap other fields
-fail_compilation/test13536.d(23): Error: address of variable `s` assigned to `u` with longer lifetime
+fail_compilation/test13536.d(23): Deprecation: address of variable `s` assigned to `u` with longer lifetime
 fail_compilation/test13536.d(24): Error: field `U.safeDg` cannot access pointers in `@safe` code that overlap other fields
 ---
 */
index 92dd3cf59d6031940a7d8c4d25776c39ea23d6af..9f628caf2198d7f94900fe75b8daacba92123698 100644 (file)
@@ -1,11 +1,11 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/test14496.d(21): Error: variable `test14496.foo.f` `void` initializers for pointers not allowed in safe functions
-fail_compilation/test14496.d(24): Error: variable `test14496.foo.Bar.foo` `void` initializers for pointers not allowed in safe functions
-fail_compilation/test14496.d(28): Error: variable `test14496.foo.Baz.x` `void` initializers for pointers not allowed in safe functions
-fail_compilation/test14496.d(48): Error: variable `test14496.sinister.bar` `void` initializers for pointers not allowed in safe functions
-fail_compilation/test14496.d(49): Error: variable `test14496.sinister.baz` `void` initializers for pointers not allowed in safe functions
+fail_compilation/test14496.d(21): Error: `void` initializers for pointers not allowed in safe functions
+fail_compilation/test14496.d(24): Error: `void` initializers for pointers not allowed in safe functions
+fail_compilation/test14496.d(28): Error: `void` initializers for pointers not allowed in safe functions
+fail_compilation/test14496.d(48): Error: `void` initializers for pointers not allowed in safe functions
+fail_compilation/test14496.d(49): Error: `void` initializers for pointers not allowed in safe functions
 ---
 */
 // https://issues.dlang.org/show_bug.cgi?id=14496
index f2a117c0b80e7d216f7f08053896443d9caba976..fbbc1c0fa88a3c248ea3da56d65f301155d8cfc7 100644 (file)
@@ -1,12 +1,11 @@
 /* TEST_OUTPUT:
 REQUIRED_ARGS: -preview=dip1000
 ---
-fail_compilation/test15191.d(35): Error: returning `&identity(x)` escapes a reference to local variable `x`
-fail_compilation/test15191.d(41): Error: returning `&identityPtr(x)` escapes a reference to local variable `x`
-fail_compilation/test15191.d(47): Error: cannot take address of `ref return` of `identityPtr()` in `@safe` function `addrOfRefTransitive`
-fail_compilation/test15191.d(47):        return type `int*` has pointers that may be `scope`
-fail_compilation/test15191.d(68): Error: cannot slice static array of `ref return` of `identityArr()` in `@safe` function `sliceOfRefEscape`
-fail_compilation/test15191.d(68):        return type `int*[1]` has pointers that may be `scope`
+fail_compilation/test15191.d(34): Error: returning `&identity(x)` escapes a reference to local variable `x`
+fail_compilation/test15191.d(40): Error: returning `&identityPtr(x)` escapes a reference to local variable `x`
+fail_compilation/test15191.d(46): Error: returning `&identityPtr(x)` escapes a reference to local variable `x`
+fail_compilation/test15191.d(67): Error: cannot take address of `scope` variable `x` since `scope` applies to first indirection only
+fail_compilation/test15191.d(69): Error: cannot take address of `scope` variable `x` since `scope` applies to first indirection only
 ---
 */
 
@@ -61,10 +60,24 @@ ref int*[1] identityArr(return ref scope int*[1] x)
        return x;
 }
 
-int* sliceOfRefEscape()
+int*[] sliceOfRefEscape()
 {
        int stackVar = 0xFF;
        scope int*[1] x = [&stackVar];
-       int*[] y = identityArr(x)[];
-       return y[0];
+       auto y = identityArr(x)[]; // check transitive scope in assignment
+       cast(void) y;
+       return identityArr(x)[]; // check transitive scope in return statement
+}
+
+// https://issues.dlang.org/show_bug.cgi?id=23079
+int** p;
+
+ref int* get() @safe
+{
+    return *p;
+}
+
+int** g1() @safe
+{
+    return &get();
 }
index 1b3cecd2d02e88f55077403cd518aaa18f62f738..02a1b32338b2b7745de91b6676a356993d26edb5 100644 (file)
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/test15373.d(21): Error: Runtime type information is not supported for `extern(C++)` classes
+fail_compilation/test15373.d(21): Error: runtime type information is not supported for `extern(C++)` classes
 ---
 */
 
index c8ab82504356b71307a3e4a79a16bab32ec7788b..c4a0fa63e75ef528801395235d14b923b935ab2c 100644 (file)
@@ -1,8 +1,8 @@
-TEST_OUTPUT:
+/* REQUIRED_ARGS: -preview=bitfields
+ * 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: unmatched closing brace
+fail_compilation/test16188.d(101): Error: no property `name` for type `test16188.Where`
+fail_compilation/test16188.d(101):        potentially malformed `opDispatch`. Use an explicit instantiation to get a better error message
 ---
  */
 
@@ -15,6 +15,8 @@ fail_compilation/test16188.d(18): Error: unmatched closing brace
  * I don't understand why.
  */
 
+#line 100
+
 void where() { Where().name; }
 
 struct Where
index a11807f645a0cc4f5d0790a56080a6d0c56bf2fc..c98796998756047dacec628d30016b2d02362705 100644 (file)
@@ -3,7 +3,7 @@ TEST_OUTPUT:
 ---
 fail_compilation/test16365.d(21): Error: `this` reference necessary to take address of member `f1` in `@safe` function `main`
 fail_compilation/test16365.d(23): Error: cannot implicitly convert expression `&f2` of type `void delegate() pure nothrow @nogc @safe` to `void function() @safe`
-fail_compilation/test16365.d(27): Error: address of variable `s` assigned to `dg` with longer lifetime
+fail_compilation/test16365.d(27): Deprecation: address of variable `s` assigned to `dg` with longer lifetime
 fail_compilation/test16365.d(28): Error: `dg.funcptr` cannot be used in `@safe` code
 ---
 */
index 5bb3c2cc9f6dacf558c6141e41592236ae772e45..b7fd9796d8be57912f02970c7988119081838691 100644 (file)
@@ -1,9 +1,10 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/test17284.d(16): Error: field `U.c` cannot access pointers in `@safe` code that overlap other fields
+fail_compilation/test17284.d(17): Error: field `U.c` cannot access pointers in `@safe` code that overlap other fields
 pure nothrow @safe void(U t)
 ---
+REQUIRED_ARGS: -preview=bitfields
 */
 
 // https://issues.dlang.org/show_bug.cgi?id=17284
index 66a81c35613811536b5d6051aec7d8bf31a57d7d..ec86646fc5a25d3fe0799c39975ef636d0c129ed 100644 (file)
@@ -1,7 +1,7 @@
 /* REQUIRED_ARGS: -preview=dip1000
 TEST_OUTPUT:
 ---
-fail_compilation/test17423.d(26): Error: reference to local `this` assigned to non-scope parameter `dlg` calling test17423.Bar.opApply
+fail_compilation/test17423.d(26): Error: reference to local `this` assigned to non-scope parameter `dlg`
 ---
 */
 
index 7833b61a9495da8ed110ea7edf37a5a732d218ee..18f18443df794c69ed917b60980ad1f9807b3e6f 100644 (file)
@@ -2,8 +2,8 @@
 TEST_OUTPUT:
 ----
 fail_compilation/test17868b.d(9): Error: pragma `crt_constructor` can only apply to a single declaration
-fail_compilation/test17868b.d(10): Error: function `test17868b.foo` must be `extern(C)` for `pragma(crt_constructor)`
-fail_compilation/test17868b.d(14): Error: function `test17868b.bar` must be `extern(C)` for `pragma(crt_constructor)`
+fail_compilation/test17868b.d(14): Error: function `test17868b.bar` must return `void` for `pragma(crt_constructor)`
+fail_compilation/test17868b.d(18): Error: function `test17868b.baz` must be `extern(C)` for `pragma(crt_constructor)` when taking parameters
 ----
  */
 pragma(crt_constructor):
@@ -11,6 +11,14 @@ void foo()
 {
 }
 
-void bar()
+extern(C) int bar()
+{
+}
+
+void baz(int argc, char** argv)
+{
+}
+
+extern(C) void bazC(int, char**)
 {
 }
index 4309a6b686722d9ce650d520f117629423c4f9e5..be296f823983dcb71f9976df3364eb61daa2301c 100644 (file)
@@ -1,7 +1,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/test18130.d(8): Error: variable `test18130.foo.v` Zero-length `out` parameters are not allowed.
+fail_compilation/test18130.d(8): Error: variable `test18130.foo.v` zero-length `out` parameters are not allowed.
 ---
 */
 // https://issues.dlang.org/show_bug.cgi?id=18130
index cf26878c39a2938f67f6c944b9bc14c4bbc439f2..580fe1bde7b3f9ddf43dd615a8407afade128f9a 100644 (file)
@@ -60,7 +60,7 @@ TEST_OUTPUT:
 fail_compilation/test18282.d(1007): Error: copying `& foo` into allocated memory escapes a reference to local variable `foo`
 fail_compilation/test18282.d(1008): Error: copying `& foo` into allocated memory escapes a reference to local variable `foo`
 fail_compilation/test18282.d(1009): Error: copying `& foo` into allocated memory escapes a reference to local variable `foo`
-fail_compilation/test18282.d(1016): Error: copying `&this` into allocated memory escapes a reference to parameter variable `this`
+fail_compilation/test18282.d(1016): Error: copying `&this` into allocated memory escapes a reference to parameter `this`
 ---
 */
 
index 55d0ff1ccc56776c81dd0049717cd7fd59aaeb3b..d604f380a18e76a49b8fefcf1ae3027da948b3c7 100644 (file)
@@ -10,11 +10,11 @@ fail_compilation/test18484.d(24): Error: escaping reference to stack allocated v
 
 struct S
 {
-    int* bar() return;
+    int* bar() @safe return;
     int i;
 }
 
-int* test1()
+int* test1() @safe
 {
     auto x = S(); return x.bar();  // error
 }
index 74c5384298f75c87dad77cb2c3b7e401c7a2417e..daa0697cffd54b606d81232599d29470dc8ac4dd 100644 (file)
@@ -2,15 +2,15 @@
 REQUIRED_ARGS: -preview=dip1000
 TEST_OUTPUT:
 ---
-fail_compilation/test20245.d(20): Error: reference to local variable `x` assigned to non-scope parameter `ptr` calling test20245.escape
-fail_compilation/test20245.d(21): Error: copying `&x` into allocated memory escapes a reference to parameter variable `x`
+fail_compilation/test20245.d(20): Error: reference to local variable `x` assigned to non-scope parameter `ptr`
+fail_compilation/test20245.d(21): Error: copying `&x` into allocated memory escapes a reference to parameter `x`
 fail_compilation/test20245.d(22): Error: scope variable `a` may not be returned
-fail_compilation/test20245.d(26): Error: cannot take address of `scope` parameter `x` in `@safe` function `foo`
-fail_compilation/test20245.d(32): Error: reference to local variable `x` assigned to non-scope parameter `ptr` calling test20245.escape
-fail_compilation/test20245.d(33): Error: copying `&x` into allocated memory escapes a reference to parameter variable `x`
+fail_compilation/test20245.d(26): Error: cannot take address of `scope` variable `x` since `scope` applies to first indirection only
+fail_compilation/test20245.d(32): Error: reference to local variable `x` assigned to non-scope parameter `ptr`
+fail_compilation/test20245.d(33): Error: copying `&x` into allocated memory escapes a reference to parameter `x`
 fail_compilation/test20245.d(49): Error: reference to local variable `price` assigned to non-scope `this.minPrice`
-fail_compilation/test20245.d(68): Error: reference to local variable `this` assigned to non-scope parameter `msg` calling object.Exception.this
-fail_compilation/test20245.d(88): Error: reference to local variable `this` assigned to non-scope parameter `content` calling test20245.listUp
+fail_compilation/test20245.d(68): Error: reference to local variable `this` assigned to non-scope parameter `msg`
+fail_compilation/test20245.d(88): Error: reference to local variable `this` assigned to non-scope parameter `content`
 ---
 */
 
index a5ac98b91361a982e5f51255e701e3761397e616..7ad50dc13083b3a0eafe5dd3ac5ec80a1c463b9b 100644 (file)
@@ -1,8 +1,8 @@
 /* REQUIRED_ARGS: -preview=dip1000
    TEST_OUTPUT:
 ---
-fail_compilation/test20569.d(19): Error: cannot take address of `scope` local `s1` in `@safe` function `main`
-fail_compilation/test20569.d(23): Error: cannot take address of `scope` local `s2` in `@safe` function `main`
+fail_compilation/test20569.d(19): Error: cannot take address of `scope` variable `s1` since `scope` applies to first indirection only
+fail_compilation/test20569.d(23): Error: cannot take address of `scope` variable `s2` since `scope` applies to first indirection only
 ---
  */
 
index cab6fc84e8991e98183a0805960203e6fbabcbd2..04c3bcff7d3c70c4fff666b38995486730416717 100644 (file)
@@ -3,7 +3,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/test21198.d(23): Error: Generating an `inout` copy constructor for `struct test21198.U` failed, therefore instances of it are uncopyable
+fail_compilation/test21198.d(23): Error: generating an `inout` copy constructor for `struct test21198.U` failed, therefore instances of it are uncopyable
 ---
 */
 
index 8732cc09c233db8002a0313aaca170850aa4a92e..45bb6d727ab30c89d2c048a32963b18f3a601d92 100644 (file)
@@ -2,7 +2,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/test21204.d(22): Error: Generating an `inout` copy constructor for `struct test21204.B` failed, therefore instances of it are uncopyable
+fail_compilation/test21204.d(22): Error: generating an `inout` copy constructor for `struct test21204.B` failed, therefore instances of it are uncopyable
 ---
 */
 
index a3a348dd0338e921c72f4b634b1c4ec3801209b3..b4c28116e340a144d4bf6b9b2e70c06511a283ec 100644 (file)
@@ -1,6 +1,6 @@
 /* TEST_OUTPUT:
 ---
-fail_compilation/test21665.d(18): Error: variable `test21665.test1.s` `void` initializers for structs with invariants are not allowed in safe functions
+fail_compilation/test21665.d(18): Error: `void` initializers for structs with invariants are not allowed in safe functions
 fail_compilation/test21665.d(30): Error: field `U.s` cannot access structs with invariants in `@safe` code that overlap other fields
 ---
 */
index 084083cd3168fb11106c57520018058e3fbb593b..394116dd21d17e608ff7aa81e104f16955c576c6 100644 (file)
@@ -1,4 +1,5 @@
 /* TEST_OUTPUT:
+REQUIRED_ARGS: -preview=dip1000
 ---
 fail_compilation/test22145.d(115): Error: scope variable `x` assigned to non-scope `global`
 ---
index f90287e9e06e6a6d4f73afdce4ee681a96c0af4a..a47c0fe95b761dd76e3800620d77b6eea402b051 100644 (file)
@@ -3,7 +3,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/test22593.d(14): Error: Cannot define both an rvalue constructor and a copy constructor for `struct Foo`
+fail_compilation/test22593.d(14): Error: cannot define both an rvalue constructor and a copy constructor for `struct Foo`
 fail_compilation/test22593.d(22):        Template instance `__ctor!(immutable(Foo!int), immutable(Foo!int))` creates a rvalue constructor for `struct Foo`
 fail_compilation/test22593.d(22): Error: template instance `test22593.Foo!int.Foo.__ctor!(immutable(Foo!int), immutable(Foo!int))` error instantiating
 ---
index e65afece6ff1d99411b7ece9f8cb930c3946fbe0..5f66b360fec10139cfee13b0d92721fe1af06e48 100644 (file)
@@ -3,7 +3,7 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/test9150.d(14): Error: mismatched array lengths, 5 and 3
+fail_compilation/test9150.d(14): Error: mismatched array lengths 5 and 3 for assignment `row[] = __r2[__key3]`
 ---
 */
 
index 5b9daaabf91c16607e590dae05020245f0d1656c..8c16afe75b20c8df77052fb5976afe96fcefbb74 100644 (file)
@@ -11,13 +11,13 @@ fail_compilation/traits.d(200): Error: undefined identifier `imports.nonexistent
 fail_compilation/traits.d(201): Error: undefined identifier `imports.nonexistent`
 fail_compilation/traits.d(202): Error: expected 1 arguments for `isPackage` but had 0
 fail_compilation/traits.d(203): Error: expected 1 arguments for `isModule` but had 0
-fail_compilation/traits.d(300): Error: In expression `__traits(allMembers, float)` `float` can't have members
+fail_compilation/traits.d(300): Error: in expression `__traits(allMembers, float)` `float` can't have members
 fail_compilation/traits.d(300):        `float` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation
-fail_compilation/traits.d(306): Error: In expression `__traits(allMembers, TemplatedStruct)` struct `TemplatedStruct(T)` has no members
+fail_compilation/traits.d(306): Error: in expression `__traits(allMembers, TemplatedStruct)` struct `TemplatedStruct(T)` has no members
 fail_compilation/traits.d(306):        `TemplatedStruct(T)` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation
-fail_compilation/traits.d(309): Error: In expression `__traits(derivedMembers, float)` `float` can't have members
+fail_compilation/traits.d(309): Error: in expression `__traits(derivedMembers, float)` `float` can't have members
 fail_compilation/traits.d(309):        `float` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation
-fail_compilation/traits.d(316): Error: In expression `__traits(derivedMembers, TemplatedStruct)` struct `TemplatedStruct(T)` has no members
+fail_compilation/traits.d(316): Error: in expression `__traits(derivedMembers, TemplatedStruct)` struct `TemplatedStruct(T)` has no members
 fail_compilation/traits.d(316):        `TemplatedStruct(T)` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation
 fail_compilation/traits.d(404): Error: function `traits.func1` circular reference in `__traits(GetCppNamespaces,...)`
 fail_compilation/traits.d(413): Error: function `traits.foo1.func1` circular reference in `__traits(GetCppNamespaces,...)`
index ec760bd60b7600ad3c8168a2ade1ceed6f618c11..5d0390f4f297c70587a176a2f8b5e2a35ce87052 100644 (file)
@@ -12,8 +12,8 @@ fail_compilation/udaparams.d(40): Error: `@safe` attribute for function paramete
 fail_compilation/udaparams.d(43): Error: `@system` attribute for function parameter is not supported
 fail_compilation/udaparams.d(44): Error: `@trusted` attribute for function parameter is not supported
 fail_compilation/udaparams.d(45): Error: `@nogc` attribute for function parameter is not supported
-fail_compilation/udaparams.d(51): Error: Cannot put a storage-class in an alias declaration.
-fail_compilation/udaparams.d(52): Error: Cannot put a storage-class in an alias declaration.
+fail_compilation/udaparams.d(51): Error: cannot put a storage-class in an alias declaration.
+fail_compilation/udaparams.d(52): Error: cannot put a storage-class in an alias declaration.
 fail_compilation/udaparams.d(53): Error: semicolon expected to close `alias` declaration
 fail_compilation/udaparams.d(53): Error: declaration expected, not `=>`
 fail_compilation/udaparams.d(54): Error: semicolon expected to close `alias` declaration
diff --git a/gcc/testsuite/gdc.test/runnable/bit.d b/gcc/testsuite/gdc.test/runnable/bit.d
new file mode 100644 (file)
index 0000000..289e1bc
--- /dev/null
@@ -0,0 +1,106 @@
+/* REQUIRED_ARGS: -preview=bitfields
+ */
+
+struct T
+{
+    uint x : 2, y : 3, :0;
+    int :0;
+}
+
+uint foo(T s)
+{
+    return s.x + s.y;
+}
+
+void test1()
+{
+    T s;
+    s.x = 2;
+    s.y = 4;
+    uint u = foo(s);
+    assert(u == 6);
+}
+
+/********************************************/
+
+struct S
+{
+    uint a:3;
+    uint b:1;
+    ulong c:64;
+
+    int d:3;
+    int e:1;
+    long f:64;
+
+    int i;
+    alias f this;
+}
+
+static assert(S.a.min == 0);
+static assert(S.a.max == 7);
+
+static assert(S.b.min == 0);
+static assert(S.b.max == 1);
+
+static assert(S.c.min == 0);
+static assert(S.c.max == ulong.max);
+
+static assert(S.d.min == -4);
+static assert(S.d.max == 3);
+
+static assert(S.e.min == -1);
+static assert(S.e.max == 0);
+
+static assert(S.f.min == long.min);
+static assert(S.f.max == long.max);
+static assert(S.max == S.f.max);
+
+void test2()
+{
+    int x;
+    S effect()
+    {
+        ++x;
+        return S();
+    }
+    assert(effect().a.max == 7);
+    assert(effect().i.max == int.max);
+    assert(x == 0); // ensure effect() was not executed
+}
+
+/********************************************/
+
+struct U
+{
+    int a;
+    int b:3, c:4;
+    this(this)
+    {
+       b = 2;
+    }
+}
+
+static assert(U.b.offsetof == 4);
+static assert(U.b.sizeof == 4);
+
+void test3()
+{
+    U u;
+    u.c = 4;
+    U v = u;
+    assert(v.c == 4);
+    u = v;
+    assert(u.b == 2);
+    assert(__traits(getMember, u, "b") == 2);
+}
+
+/********************************************/
+
+int main()
+{
+    test1();
+    test2();
+    test3();
+    return 0;
+}
diff --git a/gcc/testsuite/gdc.test/runnable/dbitfields.d b/gcc/testsuite/gdc.test/runnable/dbitfields.d
new file mode 100644 (file)
index 0000000..0d1877a
--- /dev/null
@@ -0,0 +1,189 @@
+/* REQUIRED_ARGS: -preview=bitfields
+ */
+
+struct S
+{
+    int a:2, b:4;
+}
+
+static assert(S.sizeof == 4);
+
+void test1()
+{
+    S s;
+    s.a = 3;
+    assert(s.a == -1);
+
+    s.b = 4;
+    assert(s.b == 4);
+}
+
+/******************************************/
+
+struct S2
+{
+    uint a:2, b:4;
+}
+
+S2 foo()
+{
+    S2 s = { 7, 8 };     // test struct literal expressions
+    return s;
+}
+
+void test2()
+{
+    S2 s = foo();
+
+    assert(s.a == 3);
+    assert(s.b == 8);
+}
+
+/******************************************/
+
+struct S3
+{
+    int i1;
+    uint a:2, b:4, c:6;
+    int i2;
+}
+
+static assert(S3.sizeof == 12);
+
+S3 s3 = { 63, 7, 8 };
+
+void test3()
+{
+    assert(s3.i1 == 63);
+    assert(s3.a == 3);
+    assert(s3.b == 8);
+    assert(s3.c == 0);
+    assert(s3.i2 == 0);
+}
+
+/******************************************/
+
+struct S4
+{
+    int i1;
+    uint a:2, b:31;
+}
+
+static assert(S4.sizeof == 12);
+
+S4 s4 = { 63, 7, 8 };
+
+void test4()
+{
+    assert(s4.i1 == 63);
+    assert(s4.a == 3);
+    assert(s4.b == 8);
+}
+
+/******************************************/
+
+struct S5
+{
+    int i1;
+    uint a:2, :0, b:5;
+}
+
+static assert(S5.sizeof == 12);
+
+S5 s5 = { 63, 7, 8 };
+
+void test5()
+{
+    assert(s5.i1 == 63);
+    assert(s5.a == 3);
+    assert(s5.b == 8);
+}
+
+/******************************************/
+
+// https://issues.dlang.org/show_bug.cgi?id=22710
+
+struct S6
+{
+    uint a:2, b:2;
+}
+
+int boo6()
+{
+    S s;
+    s.a = 3;
+    s.b = 1;
+    s.a += 2;
+    return s.a;
+}
+
+void test6()
+{
+    //printf("res: %d\n", test());
+    assert(boo6() == 1);
+}
+
+/******************************************/
+
+// https://issues.dlang.org/show_bug.cgi?id=22710
+
+struct S7
+{
+    uint a:2, b:2;
+    int c:2, d:2;
+}
+
+int test7u()
+{
+    S7 s;
+    s.a = 7;
+    s.b = 1;
+    s.a += 2;
+    return s.a;
+}
+
+int test7s()
+{
+    S7 s;
+    s.c = 7;
+    s.d = 1;
+    s.c += 4;
+    return s.c;
+}
+
+int test7s2()
+{
+    S7 s;
+    s.c = 7;
+    s.d = 2;
+    s.c += 4;
+    return s.d;
+}
+
+void test7()
+{
+    //printf("uns: %d\n", test7u());
+    assert(test7u() == 1);
+    //printf("sig: %d\n", test7s());
+    assert(test7s() == -1);
+    assert(test7s2() == -2);
+}
+
+static assert(test7u() ==  1);
+static assert(test7s() == -1);
+static assert(test7s2() == -2);
+
+/******************************************/
+
+int main()
+{
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+    test6();
+    test7();
+
+    return 0;
+}
index 6b1e89b65ff8e35e4561ce2a04d6396037a91d06..16d4c5570a416b750482c45fa770d5820c4f8471 100644 (file)
@@ -3453,6 +3453,21 @@ void test113()
     }
 }
 
+/************************************************/
+
+bool test114()
+{
+    string fizzBuzz()
+    {
+        string result = "fizz ";
+        return result ~= "buzz";
+    }
+
+    assert(fizzBuzz() == "fizz buzz");
+    return true;
+}
+static assert(test114());
+
 /************************************************/
 // https://issues.dlang.org/show_bug.cgi?id=14140
 
@@ -3852,6 +3867,7 @@ int main()
     test109();
     test112();
     test113();
+    test114();
     test6439();
     test6504();
     test8818();
index d28cae29edc1bc4586bcd1adec78ac0e11faedac..44d6951879c18a623b277d692c595ae2c1a32c3d 100644 (file)
@@ -12,8 +12,6 @@ fini
 
 import core.stdc.stdio;
 
-extern(C):
-
 pragma(crt_constructor)
 pragma(crt_destructor)
 void ctor_dtor_1()
@@ -45,7 +43,7 @@ template fini()
 
 alias instantiate = fini!();
 
-int main()
+extern(C) int main()
 {
     puts("main");
     return 0;
diff --git a/gcc/testsuite/gdc.test/runnable/test20734.d b/gcc/testsuite/gdc.test/runnable/test20734.d
new file mode 100644 (file)
index 0000000..264602b
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+REQUIRED_ARGS: -betterC -preview=dip1000
+*/
+
+__gshared int numDtor;
+
+struct S
+{
+    int a;
+    ~this() nothrow @nogc @trusted { ++numDtor; }
+}
+
+void takeScopeSlice(const scope S[] slice) nothrow @nogc @safe {}
+
+extern(C) int main() nothrow @nogc @safe
+{
+    takeScopeSlice([ S(1), S(2) ]); // @nogc => no GC allocation
+    (() @trusted { assert(numDtor == 2); })(); // stack-allocated array literal properly destructed
+    return 0;
+}
+
+// https://issues.dlang.org/show_bug.cgi?id=23098
+void f23098(scope inout(int)[] d) @safe {}
+
+void test23098() @safe
+{
+    f23098([10, 20]);
+}
diff --git a/gcc/testsuite/gdc.test/runnable/test21416.d b/gcc/testsuite/gdc.test/runnable/test21416.d
new file mode 100644 (file)
index 0000000..88eebd8
--- /dev/null
@@ -0,0 +1,9 @@
+// https://issues.dlang.org/show_bug.cgi?id=21416
+
+// REQUIRED_ARGS: -betterC
+
+extern(C) void main() {}
+
+extern(C++) interface IEntry {}
+
+extern(C++) class MyEntryInfo : IEntry {}
diff --git a/gcc/testsuite/gdc.test/runnable/test23083.d b/gcc/testsuite/gdc.test/runnable/test23083.d
new file mode 100644 (file)
index 0000000..41c881f
--- /dev/null
@@ -0,0 +1,16 @@
+// https://issues.dlang.org/show_bug.cgi?id=23083
+int calls = 0;
+
+int[2] f()
+{
+    calls++;
+    return [123, 456];
+}
+
+void g(int a, int b) {}
+
+void main()
+{
+    g(f().tupleof);
+    assert(calls == 1);
+}
index ba0dc69b9d08a5b043839ee1e6b139c97eefc4d8..e79c6a05716ff9e2ec33b99abdf33bd880bc3f16 100644 (file)
@@ -1,19 +1,19 @@
 /* PERMUTE_ARGS: -inline -g -O
 TEST_OUTPUT:
 ---
-runnable/testcontracts.d(323): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
-runnable/testcontracts.d(324): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
-runnable/testcontracts.d(325): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
-runnable/testcontracts.d(326): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
-runnable/testcontracts.d(328): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
-runnable/testcontracts.d(329): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
-runnable/testcontracts.d(330): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
-runnable/testcontracts.d(331): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
-runnable/testcontracts.d(502): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
-runnable/testcontracts.d(503): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
-runnable/testcontracts.d(504): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
-runnable/testcontracts.d(505): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
-runnable/testcontracts.d(505): Deprecation: Usage of the `body` keyword is deprecated. Use `do` instead.
+runnable/testcontracts.d(323): Deprecation: usage of the `body` keyword is deprecated. Use `do` instead.
+runnable/testcontracts.d(324): Deprecation: usage of the `body` keyword is deprecated. Use `do` instead.
+runnable/testcontracts.d(325): Deprecation: usage of the `body` keyword is deprecated. Use `do` instead.
+runnable/testcontracts.d(326): Deprecation: usage of the `body` keyword is deprecated. Use `do` instead.
+runnable/testcontracts.d(328): Deprecation: usage of the `body` keyword is deprecated. Use `do` instead.
+runnable/testcontracts.d(329): Deprecation: usage of the `body` keyword is deprecated. Use `do` instead.
+runnable/testcontracts.d(330): Deprecation: usage of the `body` keyword is deprecated. Use `do` instead.
+runnable/testcontracts.d(331): Deprecation: usage of the `body` keyword is deprecated. Use `do` instead.
+runnable/testcontracts.d(502): Deprecation: usage of the `body` keyword is deprecated. Use `do` instead.
+runnable/testcontracts.d(503): Deprecation: usage of the `body` keyword is deprecated. Use `do` instead.
+runnable/testcontracts.d(504): Deprecation: usage of the `body` keyword is deprecated. Use `do` instead.
+runnable/testcontracts.d(505): Deprecation: usage of the `body` keyword is deprecated. Use `do` instead.
+runnable/testcontracts.d(505): Deprecation: usage of the `body` keyword is deprecated. Use `do` instead.
 ---
 */
 extern(C) int printf(const char*, ...);
index c94634f47708591ebacdd3755315b1bea4709007..1a9faf9be04704677e301db14519be91f131cc8e 100644 (file)
@@ -1,4 +1,4 @@
-e361d200b287a68344095f306cf5ea3a63c080e1
+94bd5bcb448405d90bc50113d1cfd45a0880a50d
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/druntime repository.
index 6ca4012b7133ac1c33ac767ac63554f46ed97579..260bb63340c1e069cab74633e4c112216a1339a5 100644 (file)
@@ -39,7 +39,7 @@ ALL_DRUNTIME_INSTALL_DSOURCES = $(DRUNTIME_DSOURCES) \
        $(DRUNTIME_DSOURCES_OPENBSD) $(DRUNTIME_DSOURCES_POSIX) \
        $(DRUNTIME_DSOURCES_SOLARIS) $(DRUNTIME_DSOURCES_WINDOWS) \
        $(DRUNTIME_DSOURCES_GENERATED) $(DRUNTIME_DISOURCES) \
-       $(DRUNTIME_DSOURCES_STDCXX)
+       $(DRUNTIME_DSOURCES_ELF) $(DRUNTIME_DSOURCES_STDCXX)
 
 # Setup source files depending on configure
 DRUNTIME_SOURCES_CONFIGURED =
@@ -120,7 +120,7 @@ endif
 DRUNTIME_DSOURCES_GENERATED = gcc/config.d gcc/libbacktrace.d
 
 ALL_DRUNTIME_SOURCES = $(DRUNTIME_DSOURCES) $(DRUNTIME_CSOURCES) \
-       $(DRUNTIME_DSOURCES_STDCXX) \
+       $(DRUNTIME_DSOURCES_ELF) $(DRUNTIME_DSOURCES_STDCXX) \
        $(DRUNTIME_SOURCES_CONFIGURED) $(DRUNTIME_DSOURCES_GENERATED)
 
 # Need this library to both be part of libgphobos.a, and installed separately.
@@ -253,6 +253,8 @@ DRUNTIME_DSOURCES_DRAGONFLYBSD = core/sys/dragonflybsd/dlfcn.d \
        core/sys/dragonflybsd/sys/mman.d core/sys/dragonflybsd/sys/socket.d \
        core/sys/dragonflybsd/sys/sysctl.d core/sys/dragonflybsd/time.d
 
+DRUNTIME_DSOURCES_ELF = core/sys/elf/package.d
+
 DRUNTIME_DSOURCES_FREEBSD = core/sys/freebsd/config.d \
        core/sys/freebsd/dlfcn.d core/sys/freebsd/err.d \
        core/sys/freebsd/execinfo.d core/sys/freebsd/netinet/in_.d \
index f7f78d71ff7fff97c66b2bab746a39092f19f19f..b7e2f34727819b1c41c712dc5a51e24ddb9784f5 100644 (file)
@@ -245,13 +245,14 @@ am__objects_1 = core/atomic.lo core/attribute.lo core/bitop.lo \
        rt/monitor_.lo rt/profilegc.lo rt/sections.lo rt/tlsgc.lo \
        rt/util/typeinfo.lo rt/util/utility.lo
 am__objects_2 = core/stdc/libgdruntime_la-errno_.lo
-am__objects_3 = core/stdcpp/allocator.lo core/stdcpp/array.lo \
+am__objects_3 = core/sys/elf/package.lo
+am__objects_4 = core/stdcpp/allocator.lo core/stdcpp/array.lo \
        core/stdcpp/exception.lo core/stdcpp/memory.lo \
        core/stdcpp/new_.lo core/stdcpp/string.lo \
        core/stdcpp/string_view.lo core/stdcpp/type_traits.lo \
        core/stdcpp/typeinfo.lo core/stdcpp/utility.lo \
        core/stdcpp/vector.lo core/stdcpp/xutility.lo
-am__objects_4 = core/sys/posix/aio.lo core/sys/posix/arpa/inet.lo \
+am__objects_5 = core/sys/posix/aio.lo core/sys/posix/arpa/inet.lo \
        core/sys/posix/config.lo core/sys/posix/dirent.lo \
        core/sys/posix/dlfcn.lo core/sys/posix/fcntl.lo \
        core/sys/posix/grp.lo core/sys/posix/iconv.lo \
@@ -278,8 +279,8 @@ am__objects_4 = core/sys/posix/aio.lo core/sys/posix/arpa/inet.lo \
        core/sys/posix/syslog.lo core/sys/posix/termios.lo \
        core/sys/posix/time.lo core/sys/posix/ucontext.lo \
        core/sys/posix/unistd.lo core/sys/posix/utime.lo
-@DRUNTIME_OS_POSIX_TRUE@am__objects_5 = $(am__objects_4)
-am__objects_6 = core/sys/darwin/config.lo \
+@DRUNTIME_OS_POSIX_TRUE@am__objects_6 = $(am__objects_5)
+am__objects_7 = core/sys/darwin/config.lo \
        core/sys/darwin/crt_externs.lo core/sys/darwin/dlfcn.lo \
        core/sys/darwin/err.lo core/sys/darwin/execinfo.lo \
        core/sys/darwin/fcntl.lo core/sys/darwin/ifaddrs.lo \
@@ -294,8 +295,8 @@ am__objects_6 = core/sys/darwin/config.lo \
        core/sys/darwin/sys/attr.lo core/sys/darwin/sys/cdefs.lo \
        core/sys/darwin/sys/event.lo core/sys/darwin/sys/mman.lo \
        core/sys/darwin/sys/sysctl.lo
-@DRUNTIME_OS_DARWIN_TRUE@am__objects_7 = $(am__objects_6)
-am__objects_8 = core/sys/dragonflybsd/dlfcn.lo \
+@DRUNTIME_OS_DARWIN_TRUE@am__objects_8 = $(am__objects_7)
+am__objects_9 = core/sys/dragonflybsd/dlfcn.lo \
        core/sys/dragonflybsd/err.lo core/sys/dragonflybsd/execinfo.lo \
        core/sys/dragonflybsd/netinet/in_.lo \
        core/sys/dragonflybsd/pthread_np.lo \
@@ -314,12 +315,12 @@ am__objects_8 = core/sys/dragonflybsd/dlfcn.lo \
        core/sys/dragonflybsd/sys/socket.lo \
        core/sys/dragonflybsd/sys/sysctl.lo \
        core/sys/dragonflybsd/time.lo
-@DRUNTIME_OS_DRAGONFLYBSD_TRUE@am__objects_9 = $(am__objects_8)
-am__objects_10 = core/sys/bionic/err.lo core/sys/bionic/fcntl.lo \
+@DRUNTIME_OS_DRAGONFLYBSD_TRUE@am__objects_10 = $(am__objects_9)
+am__objects_11 = core/sys/bionic/err.lo core/sys/bionic/fcntl.lo \
        core/sys/bionic/stdlib.lo core/sys/bionic/string.lo \
        core/sys/bionic/unistd.lo
-@DRUNTIME_OS_ANDROID_TRUE@am__objects_11 = $(am__objects_10)
-am__objects_12 = core/sys/freebsd/config.lo core/sys/freebsd/dlfcn.lo \
+@DRUNTIME_OS_ANDROID_TRUE@am__objects_12 = $(am__objects_11)
+am__objects_13 = core/sys/freebsd/config.lo core/sys/freebsd/dlfcn.lo \
        core/sys/freebsd/err.lo core/sys/freebsd/execinfo.lo \
        core/sys/freebsd/netinet/in_.lo core/sys/freebsd/pthread_np.lo \
        core/sys/freebsd/stdlib.lo core/sys/freebsd/string.lo \
@@ -332,8 +333,8 @@ am__objects_12 = core/sys/freebsd/config.lo core/sys/freebsd/dlfcn.lo \
        core/sys/freebsd/sys/mman.lo core/sys/freebsd/sys/mount.lo \
        core/sys/freebsd/sys/sysctl.lo core/sys/freebsd/time.lo \
        core/sys/freebsd/unistd.lo
-@DRUNTIME_OS_FREEBSD_TRUE@am__objects_13 = $(am__objects_12)
-am__objects_14 = core/sys/netbsd/dlfcn.lo core/sys/netbsd/err.lo \
+@DRUNTIME_OS_FREEBSD_TRUE@am__objects_14 = $(am__objects_13)
+am__objects_15 = core/sys/netbsd/dlfcn.lo core/sys/netbsd/err.lo \
        core/sys/netbsd/execinfo.lo core/sys/netbsd/stdlib.lo \
        core/sys/netbsd/string.lo core/sys/netbsd/sys/elf.lo \
        core/sys/netbsd/sys/elf32.lo core/sys/netbsd/sys/elf64.lo \
@@ -341,8 +342,8 @@ am__objects_14 = core/sys/netbsd/dlfcn.lo core/sys/netbsd/err.lo \
        core/sys/netbsd/sys/featuretest.lo \
        core/sys/netbsd/sys/link_elf.lo core/sys/netbsd/sys/mman.lo \
        core/sys/netbsd/sys/sysctl.lo core/sys/netbsd/time.lo
-@DRUNTIME_OS_NETBSD_TRUE@am__objects_15 = $(am__objects_14)
-am__objects_16 = core/sys/openbsd/dlfcn.lo core/sys/openbsd/err.lo \
+@DRUNTIME_OS_NETBSD_TRUE@am__objects_16 = $(am__objects_15)
+am__objects_17 = core/sys/openbsd/dlfcn.lo core/sys/openbsd/err.lo \
        core/sys/openbsd/execinfo.lo core/sys/openbsd/pthread_np.lo \
        core/sys/openbsd/pwd.lo core/sys/openbsd/stdlib.lo \
        core/sys/openbsd/string.lo core/sys/openbsd/sys/cdefs.lo \
@@ -352,8 +353,8 @@ am__objects_16 = core/sys/openbsd/dlfcn.lo core/sys/openbsd/err.lo \
        core/sys/openbsd/sys/link_elf.lo core/sys/openbsd/sys/mman.lo \
        core/sys/openbsd/sys/sysctl.lo core/sys/openbsd/time.lo \
        core/sys/openbsd/unistd.lo
-@DRUNTIME_OS_OPENBSD_TRUE@am__objects_17 = $(am__objects_16)
-am__objects_18 = core/sys/linux/config.lo core/sys/linux/dlfcn.lo \
+@DRUNTIME_OS_OPENBSD_TRUE@am__objects_18 = $(am__objects_17)
+am__objects_19 = core/sys/linux/config.lo core/sys/linux/dlfcn.lo \
        core/sys/linux/elf.lo core/sys/linux/epoll.lo \
        core/sys/linux/err.lo core/sys/linux/errno.lo \
        core/sys/linux/execinfo.lo core/sys/linux/fcntl.lo \
@@ -371,8 +372,8 @@ am__objects_18 = core/sys/linux/config.lo core/sys/linux/dlfcn.lo \
        core/sys/linux/termios.lo core/sys/linux/time.lo \
        core/sys/linux/timerfd.lo core/sys/linux/tipc.lo \
        core/sys/linux/unistd.lo
-@DRUNTIME_OS_LINUX_TRUE@am__objects_19 = $(am__objects_18)
-am__objects_20 = core/sys/windows/accctrl.lo \
+@DRUNTIME_OS_LINUX_TRUE@am__objects_20 = $(am__objects_19)
+am__objects_21 = core/sys/windows/accctrl.lo \
        core/sys/windows/aclapi.lo core/sys/windows/aclui.lo \
        core/sys/windows/basetsd.lo core/sys/windows/basetyps.lo \
        core/sys/windows/cderr.lo core/sys/windows/cguid.lo \
@@ -457,9 +458,9 @@ am__objects_20 = core/sys/windows/accctrl.lo \
        core/sys/windows/winsvc.lo core/sys/windows/winuser.lo \
        core/sys/windows/winver.lo core/sys/windows/wtsapi32.lo \
        core/sys/windows/wtypes.lo
-@DRUNTIME_OS_MINGW_TRUE@am__objects_21 = $(am__objects_20) \
+@DRUNTIME_OS_MINGW_TRUE@am__objects_22 = $(am__objects_21) \
 @DRUNTIME_OS_MINGW_TRUE@       config/mingw/libgdruntime_la-msvc.lo
-am__objects_22 = core/sys/solaris/dlfcn.lo core/sys/solaris/elf.lo \
+am__objects_23 = core/sys/solaris/dlfcn.lo core/sys/solaris/elf.lo \
        core/sys/solaris/err.lo core/sys/solaris/execinfo.lo \
        core/sys/solaris/libelf.lo core/sys/solaris/link.lo \
        core/sys/solaris/stdlib.lo core/sys/solaris/sys/elf.lo \
@@ -471,48 +472,48 @@ am__objects_22 = core/sys/solaris/dlfcn.lo core/sys/solaris/elf.lo \
        core/sys/solaris/sys/priocntl.lo \
        core/sys/solaris/sys/procset.lo core/sys/solaris/sys/types.lo \
        core/sys/solaris/time.lo
-@DRUNTIME_OS_SOLARIS_TRUE@am__objects_23 = $(am__objects_22)
-@DRUNTIME_CPU_AARCH64_TRUE@am__objects_24 = config/aarch64/libgdruntime_la-switchcontext.lo
-@DRUNTIME_CPU_ARM_TRUE@am__objects_25 = config/arm/libgdruntime_la-switchcontext.lo
-@DRUNTIME_CPU_MIPS_TRUE@am__objects_26 = config/mips/libgdruntime_la-switchcontext.lo
-@DRUNTIME_CPU_POWERPC_TRUE@am__objects_27 = config/powerpc/libgdruntime_la-switchcontext.lo
-@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_TRUE@am__objects_28 = config/mingw/libgdruntime_la-switchcontext.lo
-@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_FALSE@am__objects_29 = config/x86/libgdruntime_la-switchcontext.lo
-@DRUNTIME_CPU_SYSTEMZ_TRUE@am__objects_30 = config/systemz/libgdruntime_la-get_tls_offset.lo
-@DRUNTIME_CPU_S390_TRUE@am__objects_31 = config/s390/libgdruntime_la-get_tls_offset.lo
-am__objects_32 = $(am__objects_5) $(am__objects_7) $(am__objects_9) \
-       $(am__objects_11) $(am__objects_13) $(am__objects_15) \
-       $(am__objects_17) $(am__objects_19) $(am__objects_21) \
-       $(am__objects_23) $(am__objects_24) $(am__objects_25) \
-       $(am__objects_26) $(am__objects_27) $(am__objects_28) \
-       $(am__objects_29) $(am__objects_30) $(am__objects_31)
-am__objects_33 = gcc/config.lo gcc/libbacktrace.lo
-am__objects_34 = $(am__objects_1) $(am__objects_2) $(am__objects_3) \
-       $(am__objects_32) $(am__objects_33)
-am_libgdruntime_la_OBJECTS = $(am__objects_34)
+@DRUNTIME_OS_SOLARIS_TRUE@am__objects_24 = $(am__objects_23)
+@DRUNTIME_CPU_AARCH64_TRUE@am__objects_25 = config/aarch64/libgdruntime_la-switchcontext.lo
+@DRUNTIME_CPU_ARM_TRUE@am__objects_26 = config/arm/libgdruntime_la-switchcontext.lo
+@DRUNTIME_CPU_MIPS_TRUE@am__objects_27 = config/mips/libgdruntime_la-switchcontext.lo
+@DRUNTIME_CPU_POWERPC_TRUE@am__objects_28 = config/powerpc/libgdruntime_la-switchcontext.lo
+@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_TRUE@am__objects_29 = config/mingw/libgdruntime_la-switchcontext.lo
+@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_FALSE@am__objects_30 = config/x86/libgdruntime_la-switchcontext.lo
+@DRUNTIME_CPU_SYSTEMZ_TRUE@am__objects_31 = config/systemz/libgdruntime_la-get_tls_offset.lo
+@DRUNTIME_CPU_S390_TRUE@am__objects_32 = config/s390/libgdruntime_la-get_tls_offset.lo
+am__objects_33 = $(am__objects_6) $(am__objects_8) $(am__objects_10) \
+       $(am__objects_12) $(am__objects_14) $(am__objects_16) \
+       $(am__objects_18) $(am__objects_20) $(am__objects_22) \
+       $(am__objects_24) $(am__objects_25) $(am__objects_26) \
+       $(am__objects_27) $(am__objects_28) $(am__objects_29) \
+       $(am__objects_30) $(am__objects_31) $(am__objects_32)
+am__objects_34 = gcc/config.lo gcc/libbacktrace.lo
+am__objects_35 = $(am__objects_1) $(am__objects_2) $(am__objects_3) \
+       $(am__objects_4) $(am__objects_33) $(am__objects_34)
+am_libgdruntime_la_OBJECTS = $(am__objects_35)
 libgdruntime_la_OBJECTS = $(am_libgdruntime_la_OBJECTS)
 am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
-am__objects_35 = core/stdc/libgdruntime_convenience_la-errno_.lo
-@DRUNTIME_OS_MINGW_TRUE@am__objects_36 = $(am__objects_20) \
+am__objects_36 = core/stdc/libgdruntime_convenience_la-errno_.lo
+@DRUNTIME_OS_MINGW_TRUE@am__objects_37 = $(am__objects_21) \
 @DRUNTIME_OS_MINGW_TRUE@       config/mingw/libgdruntime_convenience_la-msvc.lo
-@DRUNTIME_CPU_AARCH64_TRUE@am__objects_37 = config/aarch64/libgdruntime_convenience_la-switchcontext.lo
-@DRUNTIME_CPU_ARM_TRUE@am__objects_38 = config/arm/libgdruntime_convenience_la-switchcontext.lo
-@DRUNTIME_CPU_MIPS_TRUE@am__objects_39 = config/mips/libgdruntime_convenience_la-switchcontext.lo
-@DRUNTIME_CPU_POWERPC_TRUE@am__objects_40 = config/powerpc/libgdruntime_convenience_la-switchcontext.lo
-@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_TRUE@am__objects_41 = config/mingw/libgdruntime_convenience_la-switchcontext.lo
-@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_FALSE@am__objects_42 = config/x86/libgdruntime_convenience_la-switchcontext.lo
-@DRUNTIME_CPU_SYSTEMZ_TRUE@am__objects_43 = config/systemz/libgdruntime_convenience_la-get_tls_offset.lo
-@DRUNTIME_CPU_S390_TRUE@am__objects_44 = config/s390/libgdruntime_convenience_la-get_tls_offset.lo
-am__objects_45 = $(am__objects_5) $(am__objects_7) $(am__objects_9) \
-       $(am__objects_11) $(am__objects_13) $(am__objects_15) \
-       $(am__objects_17) $(am__objects_19) $(am__objects_36) \
-       $(am__objects_23) $(am__objects_37) $(am__objects_38) \
-       $(am__objects_39) $(am__objects_40) $(am__objects_41) \
-       $(am__objects_42) $(am__objects_43) $(am__objects_44)
-am__objects_46 = $(am__objects_1) $(am__objects_35) $(am__objects_3) \
-       $(am__objects_45) $(am__objects_33)
-am__objects_47 = $(am__objects_46)
-am_libgdruntime_convenience_la_OBJECTS = $(am__objects_47)
+@DRUNTIME_CPU_AARCH64_TRUE@am__objects_38 = config/aarch64/libgdruntime_convenience_la-switchcontext.lo
+@DRUNTIME_CPU_ARM_TRUE@am__objects_39 = config/arm/libgdruntime_convenience_la-switchcontext.lo
+@DRUNTIME_CPU_MIPS_TRUE@am__objects_40 = config/mips/libgdruntime_convenience_la-switchcontext.lo
+@DRUNTIME_CPU_POWERPC_TRUE@am__objects_41 = config/powerpc/libgdruntime_convenience_la-switchcontext.lo
+@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_TRUE@am__objects_42 = config/mingw/libgdruntime_convenience_la-switchcontext.lo
+@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_FALSE@am__objects_43 = config/x86/libgdruntime_convenience_la-switchcontext.lo
+@DRUNTIME_CPU_SYSTEMZ_TRUE@am__objects_44 = config/systemz/libgdruntime_convenience_la-get_tls_offset.lo
+@DRUNTIME_CPU_S390_TRUE@am__objects_45 = config/s390/libgdruntime_convenience_la-get_tls_offset.lo
+am__objects_46 = $(am__objects_6) $(am__objects_8) $(am__objects_10) \
+       $(am__objects_12) $(am__objects_14) $(am__objects_16) \
+       $(am__objects_18) $(am__objects_20) $(am__objects_37) \
+       $(am__objects_24) $(am__objects_38) $(am__objects_39) \
+       $(am__objects_40) $(am__objects_41) $(am__objects_42) \
+       $(am__objects_43) $(am__objects_44) $(am__objects_45)
+am__objects_47 = $(am__objects_1) $(am__objects_36) $(am__objects_3) \
+       $(am__objects_4) $(am__objects_46) $(am__objects_34)
+am__objects_48 = $(am__objects_47)
+am_libgdruntime_convenience_la_OBJECTS = $(am__objects_48)
 libgdruntime_convenience_la_OBJECTS =  \
        $(am_libgdruntime_convenience_la_OBJECTS)
 AM_V_P = $(am__v_P_@AM_V@)
@@ -777,7 +778,7 @@ ALL_DRUNTIME_INSTALL_DSOURCES = $(DRUNTIME_DSOURCES) \
        $(DRUNTIME_DSOURCES_OPENBSD) $(DRUNTIME_DSOURCES_POSIX) \
        $(DRUNTIME_DSOURCES_SOLARIS) $(DRUNTIME_DSOURCES_WINDOWS) \
        $(DRUNTIME_DSOURCES_GENERATED) $(DRUNTIME_DISOURCES) \
-       $(DRUNTIME_DSOURCES_STDCXX)
+       $(DRUNTIME_DSOURCES_ELF) $(DRUNTIME_DSOURCES_STDCXX)
 
 
 # Setup source files depending on configure
@@ -796,7 +797,7 @@ DRUNTIME_SOURCES_CONFIGURED = $(am__append_1) $(am__append_2) \
 # Generated by configure
 DRUNTIME_DSOURCES_GENERATED = gcc/config.d gcc/libbacktrace.d
 ALL_DRUNTIME_SOURCES = $(DRUNTIME_DSOURCES) $(DRUNTIME_CSOURCES) \
-       $(DRUNTIME_DSOURCES_STDCXX) \
+       $(DRUNTIME_DSOURCES_ELF) $(DRUNTIME_DSOURCES_STDCXX) \
        $(DRUNTIME_SOURCES_CONFIGURED) $(DRUNTIME_DSOURCES_GENERATED)
 
 
@@ -918,6 +919,7 @@ DRUNTIME_DSOURCES_DRAGONFLYBSD = core/sys/dragonflybsd/dlfcn.d \
        core/sys/dragonflybsd/sys/mman.d core/sys/dragonflybsd/sys/socket.d \
        core/sys/dragonflybsd/sys/sysctl.d core/sys/dragonflybsd/time.d
 
+DRUNTIME_DSOURCES_ELF = core/sys/elf/package.d
 DRUNTIME_DSOURCES_FREEBSD = core/sys/freebsd/config.d \
        core/sys/freebsd/dlfcn.d core/sys/freebsd/err.d \
        core/sys/freebsd/execinfo.d core/sys/freebsd/netinet/in_.d \
@@ -1374,6 +1376,10 @@ rt/util/$(am__dirstamp):
 rt/util/typeinfo.lo: rt/util/$(am__dirstamp)
 rt/util/utility.lo: rt/util/$(am__dirstamp)
 core/stdc/libgdruntime_la-errno_.lo: core/stdc/$(am__dirstamp)
+core/sys/elf/$(am__dirstamp):
+       @$(MKDIR_P) core/sys/elf
+       @: > core/sys/elf/$(am__dirstamp)
+core/sys/elf/package.lo: core/sys/elf/$(am__dirstamp)
 core/stdcpp/$(am__dirstamp):
        @$(MKDIR_P) core/stdcpp
        @: > core/stdcpp/$(am__dirstamp)
@@ -2016,6 +2022,8 @@ mostlyclean-compile:
        -rm -f core/sys/dragonflybsd/netinet/*.lo
        -rm -f core/sys/dragonflybsd/sys/*.$(OBJEXT)
        -rm -f core/sys/dragonflybsd/sys/*.lo
+       -rm -f core/sys/elf/*.$(OBJEXT)
+       -rm -f core/sys/elf/*.lo
        -rm -f core/sys/freebsd/*.$(OBJEXT)
        -rm -f core/sys/freebsd/*.lo
        -rm -f core/sys/freebsd/netinet/*.$(OBJEXT)
@@ -2184,6 +2192,7 @@ clean-libtool:
        -rm -rf core/sys/dragonflybsd/.libs core/sys/dragonflybsd/_libs
        -rm -rf core/sys/dragonflybsd/netinet/.libs core/sys/dragonflybsd/netinet/_libs
        -rm -rf core/sys/dragonflybsd/sys/.libs core/sys/dragonflybsd/sys/_libs
+       -rm -rf core/sys/elf/.libs core/sys/elf/_libs
        -rm -rf core/sys/freebsd/.libs core/sys/freebsd/_libs
        -rm -rf core/sys/freebsd/netinet/.libs core/sys/freebsd/netinet/_libs
        -rm -rf core/sys/freebsd/sys/.libs core/sys/freebsd/sys/_libs
@@ -2345,6 +2354,7 @@ distclean-generic:
        -rm -f core/sys/dragonflybsd/$(am__dirstamp)
        -rm -f core/sys/dragonflybsd/netinet/$(am__dirstamp)
        -rm -f core/sys/dragonflybsd/sys/$(am__dirstamp)
+       -rm -f core/sys/elf/$(am__dirstamp)
        -rm -f core/sys/freebsd/$(am__dirstamp)
        -rm -f core/sys/freebsd/netinet/$(am__dirstamp)
        -rm -f core/sys/freebsd/sys/$(am__dirstamp)
index e5c448e00cfee10d2df5f21bc93768cee7b5880a..cf05333429ed36653935bfaf49c1f8f0fa67902e 100644 (file)
@@ -19,25 +19,23 @@ module __builtins;
  * into the D compiler.
  */
 
-import core.stdc.stdarg;
-
-alias va_list = core.stdc.stdarg.va_list;
+alias va_list = imported!"core.stdc.stdarg".va_list;
 
 version (Posix)
 {
     version (X86_64)
-        alias __va_list_tag = core.stdc.stdarg.__va_list_tag;
+        alias __va_list_tag = imported!"core.stdc.stdarg".__va_list_tag;
 }
 
-alias __builtin_va_start = core.stdc.stdarg.va_start;
+alias __builtin_va_start = imported!"core.stdc.stdarg".va_start;
 
-alias __builtin_va_end = core.stdc.stdarg.va_end;
+alias __builtin_va_end = imported!"core.stdc.stdarg".va_end;
 
-alias __builtin_va_copy = core.stdc.stdarg.va_copy;
+alias __builtin_va_copy = imported!"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;
+alias va_arg = imported!"core.stdc.stdarg".va_arg;
 
 version (CRuntime_Microsoft)
 {
@@ -63,11 +61,9 @@ version (DigitalMars)
     alias __builtin_huge_valf = __builtin_inff;
     alias __builtin_huge_vall = __builtin_infl;
 
-    import core.stdc.math;
-
-    alias __builtin_fabs  = core.stdc.math.fabs;
-    alias __builtin_fabsf = core.stdc.math.fabsf;
-    alias __builtin_fabsl = core.stdc.math.fabsl;
+    alias __builtin_fabs  = imported!"core.stdc.math".fabs;
+    alias __builtin_fabsf = imported!"core.stdc.math".fabsf;
+    alias __builtin_fabsl = imported!"core.stdc.math".fabsl;
 
     ushort __builtin_bswap16()(ushort value)
     {
@@ -87,10 +83,13 @@ version (DigitalMars)
         return core.bitop.bswap(value);
     }
 
+    // Lazily imported on first use
+    private alias c_long = imported!"core.stdc.config".c_long;
+
     // Stub these out to no-ops
-    int   __builtin_constant_p(T)(T exp) { return 0; } // should be something like __traits(compiles, enum X = expr)
-    long  __builtin_expect()(long exp, long c) { return exp; }
-    void* __builtin_assume_aligned()(const void* p, size_t align_, ...) { return cast(void*)p; }
+    int    __builtin_constant_p(T)(T exp) { return 0; } // should be something like __traits(compiles, enum X = expr)
+    c_long __builtin_expect()(c_long exp, c_long c) { return exp; }
+    void*  __builtin_assume_aligned()(const void* p, size_t align_, ...) { return cast(void*)p; }
 
     // https://releases.llvm.org/13.0.0/tools/clang/docs/LanguageExtensions.html#builtin-assume
     void __builtin_assume(T)(lazy T arg) { }
index 172263c684a295a5610bf2b7ac154499685fc2de..5d4f3b498f91ac34f12f62ab699b469810b65b44 100644 (file)
@@ -76,79 +76,55 @@ template _d_arrayappendcTXImpl(Tarr : T[], T)
     alias _d_arrayappendcTXTrace = _d_HookTraceImpl!(Tarr, _d_arrayappendcTX, errorMessage);
 }
 
-/// Implementation of `_d_arrayappendT` and `_d_arrayappendTTrace`
-template _d_arrayappendTImpl(Tarr : T[], T)
+/// Implementation of `_d_arrayappendT`
+ref Tarr _d_arrayappendT(Tarr : T[], T)(return ref scope Tarr x, scope Tarr y) @trusted
 {
-    import core.internal.array.utils : _d_HookTraceImpl;
-
-    private enum errorMessage = "Cannot append to array if compiling without support for runtime type information!";
-
-    /**
-     * Append array `y` to array `x`.
-     * Params:
-     *  x = what array to append to, taken as a reference
-     *  y = what should be appended
-     * Returns:
-     *  The new value of `x`
-     * Bugs:
-    *   This function template was ported from a much older runtime hook that bypassed safety,
-    *   purity, and throwabilty checks. To prevent breaking existing code, this function template
-    *   is temporarily declared `@trusted pure` until the implementation can be brought up to modern D expectations.
-     */
-    static if (isCopyingNothrow!T)
-        ref Tarr _d_arrayappendT(return ref scope Tarr x, scope Tarr y) @trusted pure nothrow
-        {
-            pragma(inline, false);
+    pragma(inline, false);
 
-            mixin(_d_arrayappendTBody);
-        }
-    else
-        ref Tarr _d_arrayappendT(return ref scope Tarr x, scope Tarr y) @trusted pure
-        {
-            pragma(inline, false);
-
-            mixin(_d_arrayappendTBody);
-        }
+    import core.stdc.string : memcpy;
+    import core.internal.traits : hasElaborateCopyConstructor, Unqual;
+    import core.lifetime : copyEmplace;
 
-    private enum _d_arrayappendTBody = q{
-        import core.stdc.string : memcpy;
-        import core.internal.traits : hasElaborateCopyConstructor, Unqual;
-        import core.lifetime : copyEmplace;
+    auto length = x.length;
 
-        auto length = x.length;
+    _d_arrayappendcTXImpl!Tarr._d_arrayappendcTX(x, y.length);
 
-        _d_arrayappendcTXImpl!Tarr._d_arrayappendcTX(x, y.length);
+    static if (hasElaborateCopyConstructor!T)
+    {
+        foreach (i, ref elem; y)
+            copyEmplace(elem, x[length + i]);
+    }
+    else
+    {
+        // blit all elements at once
+        if (y.length)
+            memcpy(cast(Unqual!T *)&x[length], cast(Unqual!T *)&y[0], y.length * T.sizeof);
+    }
 
-        static if (hasElaborateCopyConstructor!T)
-        {
-            foreach (i; 0 .. y.length)
-                copyEmplace(y[i], x[length + i]);
-        }
-        else
-        {
-            // blit all elements at once
-            if (y.length)
-                memcpy(cast(Unqual!T *)&x[length], cast(Unqual!T *)&y[0], y.length * T.sizeof);
-        }
+    return x;
+}
 
-        return x;
-    };
+/**
+ * TraceGC wrapper around $(REF _d_arrayappendT, core,internal,array,appending).
+ */
+ref Tarr _d_arrayappendTTrace(Tarr : T[], T)(string file, int line, string funcname, return ref scope Tarr x, scope Tarr y) @trusted
+{
+    version (D_TypeInfo)
+    {
+        import core.internal.array.utils: TraceHook, gcStatsPure, accumulatePure;
+        mixin(TraceHook!(Tarr.stringof, "_d_arrayappendT"));
 
-    /**
-     * TraceGC wrapper around $(REF _d_arrayappendT, rt,array,appending,_d_arrayappendTImpl).
-     * Bugs:
-     *  This function template was ported from a much older runtime hook that bypassed safety,
-     *  purity, and throwabilty checks. To prevent breaking existing code, this function template
-     *  is temporarily declared `@trusted pure` until the implementation can be brought up to modern D expectations.
-     */
-    alias _d_arrayappendTTrace = _d_HookTraceImpl!(Tarr, _d_arrayappendT, errorMessage);
+        return _d_arrayappendT(x, y);
+    }
+    else
+        assert(0, "Cannot append to array if compiling without support for runtime type information!");
 }
 
 @safe unittest
 {
     double[] arr1;
     foreach (i; 0 .. 4)
-        _d_arrayappendTImpl!(typeof(arr1))._d_arrayappendT(arr1, [cast(double)i]);
+        _d_arrayappendT(arr1, [cast(double)i]);
     assert(arr1 == [0.0, 1.0, 2.0, 3.0]);
 }
 
@@ -167,7 +143,7 @@ template _d_arrayappendTImpl(Tarr : T[], T)
     Item[] arr2 = [Item(), Item()];
     Item[] arr1_org = [Item(), Item()];
     arr1_org ~= arr2;
-    _d_arrayappendTImpl!(typeof(arr1))._d_arrayappendT(arr1, arr2);
+    _d_arrayappendT(arr1, arr2);
 
     // postblit should have triggered on at least the items in arr2
     assert(blitted >= arr2.length);
@@ -187,7 +163,7 @@ template _d_arrayappendTImpl(Tarr : T[], T)
     Item[][] arr1 = [[Item()]];
     Item[][] arr2 = [[Item()]];
 
-    _d_arrayappendTImpl!(typeof(arr1))._d_arrayappendT(arr1, arr2);
+    _d_arrayappendT(arr1, arr2);
 
     // no postblit should have happened because arr{1,2} contain dynamic arrays
     assert(blitted == 0);
@@ -207,7 +183,7 @@ template _d_arrayappendTImpl(Tarr : T[], T)
     Item[1][] arr1 = [[Item()]];
     Item[1][] arr2 = [[Item()]];
 
-    _d_arrayappendTImpl!(typeof(arr1))._d_arrayappendT(arr1, arr2);
+    _d_arrayappendT(arr1, arr2);
     // copy constructor should have been invoked because arr{1,2} contain static arrays
     assert(copied >= arr2.length);
 }
@@ -215,8 +191,8 @@ template _d_arrayappendTImpl(Tarr : T[], T)
 @safe nothrow unittest
 {
     string str;
-    _d_arrayappendTImpl!(typeof(str))._d_arrayappendT(str, "a");
-    _d_arrayappendTImpl!(typeof(str))._d_arrayappendT(str, "b");
-    _d_arrayappendTImpl!(typeof(str))._d_arrayappendT(str, "c");
+    _d_arrayappendT(str, "a");
+    _d_arrayappendT(str, "b");
+    _d_arrayappendT(str, "c");
     assert(str == "abc");
 }
index 7a829a0b3f708966395e6bc5119c5af44a91d6f1..41aa57faf0ce6fd1bfa6a69dec3187daeec54d47 100644 (file)
@@ -11,7 +11,7 @@ module core.internal.array.utils;
 
 import core.internal.traits : Parameters;
 
-private auto gcStatsPure() nothrow pure
+auto gcStatsPure() nothrow pure
 {
     import core.memory : GC;
 
@@ -19,7 +19,7 @@ private auto gcStatsPure() nothrow pure
     return impureBypass();
 }
 
-private ulong accumulatePure(string file, int line, string funcname, string name, ulong size) nothrow pure
+ulong accumulatePure(string file, int line, string funcname, string name, ulong size) nothrow pure
 {
     static ulong impureBypass(string file, int line, string funcname, string name, ulong size) @nogc nothrow
     {
@@ -35,41 +35,32 @@ private ulong accumulatePure(string file, int line, string funcname, string name
 }
 
 /**
- * TraceGC wrapper around runtime hook `Hook`.
+ * TraceGC wrapper generator around the runtime hook `Hook`.
  * Params:
- *  T = Type of hook to report to accumulate
- *  Hook = The hook to wrap
- *  errorMessage = The error message incase `version != D_TypeInfo`
- *  file = File that called `_d_HookTraceImpl`
- *  line = Line inside of `file` that called `_d_HookTraceImpl`
- *  funcname = Function that called `_d_HookTraceImpl`
- *  parameters = Parameters that will be used to call `Hook`
- * Bugs:
- *  This function template needs be between the compiler and a much older runtime hook that bypassed safety,
- *  purity, and throwabilty checks. To prevent breaking existing code, this function template
- *  is temporarily declared `@trusted pure` until the implementation can be brought up to modern D expectations.
-*/
-auto _d_HookTraceImpl(T, alias Hook, string errorMessage)(string file, int line, string funcname, Parameters!Hook parameters) @trusted pure
+ *   Type = The type of hook to report to accumulate
+ *   Hook = The name hook to wrap
+ */
+template TraceHook(string Type, string Hook)
 {
-    version (D_TypeInfo)
-    {
+    const char[] TraceHook = q{
+        import core.internal.array.utils : gcStatsPure, accumulatePure;
+
         pragma(inline, false);
-        string name = T.stringof;
+        string name = } ~ "`" ~ Type ~ "`;" ~ q{
 
         // FIXME: use rt.tracegc.accumulator when it is accessable in the future.
         version (tracegc)
-        {
+    } ~ "{\n" ~ q{
             import core.stdc.stdio;
 
             printf("%sTrace file = '%.*s' line = %d function = '%.*s' type = %.*s\n",
-                Hook.stringof.ptr,
+            } ~ "\"" ~ Hook ~ "\".ptr," ~ q{
                 file.length, file.ptr,
                 line,
                 funcname.length, funcname.ptr,
                 name.length, name.ptr
             );
-        }
-
+        } ~ "}\n" ~ q{
         ulong currentlyAllocated = gcStatsPure().allocatedInCurrentThread;
 
         scope(exit)
@@ -86,6 +77,29 @@ auto _d_HookTraceImpl(T, alias Hook, string errorMessage)(string file, int line,
                     assert(0);
                 }
         }
+    };
+}
+
+/**
+ * TraceGC wrapper around runtime hook `Hook`.
+ * Params:
+ *  T = Type of hook to report to accumulate
+ *  Hook = The hook to wrap
+ *  errorMessage = The error message incase `version != D_TypeInfo`
+ *  file = File that called `_d_HookTraceImpl`
+ *  line = Line inside of `file` that called `_d_HookTraceImpl`
+ *  funcname = Function that called `_d_HookTraceImpl`
+ *  parameters = Parameters that will be used to call `Hook`
+ * Bugs:
+ *  This function template needs be between the compiler and a much older runtime hook that bypassed safety,
+ *  purity, and throwabilty checks. To prevent breaking existing code, this function template
+ *  is temporarily declared `@trusted pure` until the implementation can be brought up to modern D expectations.
+*/
+auto _d_HookTraceImpl(T, alias Hook, string errorMessage)(string file, int line, string funcname, Parameters!Hook parameters) @trusted pure
+{
+    version (D_TypeInfo)
+    {
+        mixin(TraceHook!(T.stringof, __traits(identifier, Hook)));
         return Hook(parameters);
     }
     else
index 0d733f2b384aefab3acefba390fed2ff7a31c5ab..0b4890cbfa9cc780253b0925ea7477dd969b8650 100644 (file)
@@ -234,7 +234,7 @@ if (Ts.length > 0)
 template classInstanceAlignment(T)
 if (is(T == class))
 {
-    alias classInstanceAlignment = maxAlignment!(void*, typeof(T.tupleof));
+    enum classInstanceAlignment = __traits(classInstanceAlignment, T);
 }
 
 /// See $(REF hasElaborateMove, std,traits)
index 47fed9dc5140f7b88d2f0b37724806956d1c2aef..6502e595e002aa547c13eb9a06a1b8265a10adf8 100644 (file)
@@ -200,12 +200,10 @@ Returns: The newly constructed object.
 T emplace(T, Args...)(void[] chunk, auto ref Args args)
     if (is(T == class))
 {
-    import core.internal.traits : maxAlignment;
-
     enum classSize = __traits(classInstanceSize, T);
     assert(chunk.length >= classSize, "chunk size too small.");
 
-    enum alignment = maxAlignment!(void*, typeof(T.tupleof));
+    enum alignment = __traits(classInstanceAlignment, T);
     assert((cast(size_t) chunk.ptr) % alignment == 0, "chunk is not aligned.");
 
     return emplace!T(cast(T)(chunk.ptr), forward!args);
@@ -242,9 +240,7 @@ T emplace(T, Args...)(void[] chunk, auto ref Args args)
         int virtualGetI() { return i; }
     }
 
-    import core.internal.traits : classInstanceAlignment;
-
-    align(classInstanceAlignment!C) byte[__traits(classInstanceSize, C)] buffer;
+    align(__traits(classInstanceAlignment, C)) byte[__traits(classInstanceSize, C)] buffer;
     C c = emplace!C(buffer[], 42);
     assert(c.virtualGetI() == 42);
 }
@@ -290,7 +286,8 @@ T emplace(T, Args...)(void[] chunk, auto ref Args args)
     }
 
     int var = 6;
-    align(__conv_EmplaceTestClass.alignof) ubyte[__traits(classInstanceSize, __conv_EmplaceTestClass)] buf;
+    align(__traits(classInstanceAlignment, __conv_EmplaceTestClass))
+        ubyte[__traits(classInstanceSize, __conv_EmplaceTestClass)] buf;
     auto support = (() @trusted => cast(__conv_EmplaceTestClass)(buf.ptr))();
 
     auto fromRval = emplace!__conv_EmplaceTestClass(support, 1);
@@ -1198,7 +1195,7 @@ pure nothrow @safe /* @nogc */ unittest
     }
     void[] buf;
 
-    static align(A.alignof) byte[__traits(classInstanceSize, A)] sbuf;
+    static align(__traits(classInstanceAlignment, A)) byte[__traits(classInstanceSize, A)] sbuf;
     buf = sbuf[];
     auto a = emplace!A(buf, 55);
     assert(a.x == 55 && a.y == 55);
index 27c84e7f55e2826aede9ec468859a5fba224190a..b63b11100c1f52dd496fb3b44b4a178242f6ceed 100644 (file)
@@ -31,7 +31,7 @@
         $(LI Maintain another reference to that same data in another thread that the
         GC does know about.)
         $(LI Disable GC collection cycles while that thread is active with $(LREF disable)/$(LREF enable).)
-        $(LI Register the thread with the GC using $(REF thread_attachThis, core,thread)/$(REF thread_detachThis, core,thread).)
+        $(LI Register the thread with the GC using $(REF thread_attachThis, core,thread,osthread)/$(REF thread_detachThis, core,thread,threadbase).)
         )
    )
    )
index 11a471183193f64289bb4ea9b01a83a35036ce8b..f1bf59b0ac49f6da0b35c0309e53948e11e06994 100644 (file)
@@ -409,6 +409,28 @@ version (D_SIMD)
     *      op2    = second operand
     * Returns:
     *      result of opcode
+    * Example:
+    ---
+    import core.simd;
+    import core.stdc.stdio;
+
+    void main()
+    {
+        float4 A = [2.34f, -70000.0f, 0.00001f, 345.5f];
+        float4 R = A;
+        R = cast(float4) __simd(XMM.RCPSS, R, A);
+        printf("%g %g %g %g\n", R.array[0], R.array[1], R.array[2], R.array[3]);
+    }
+    ---
+    * Prints `0.427368 -70000 1e-05 345.5`.
+    * The use of the two operand form for `XMM.RCPSS` is necessary because the result of the instruction
+    * contains elements of both operands.
+    * Example:
+    ---
+    double[2] A = [56.0, -75.0];
+    double2 R = cast(double2) __simd(XMM.LODUPD, *cast(double2*)A.ptr);
+    ---
+    * The cast to `double2*` is necessary because the type of `*A.ptr` is `double`.
     */
     pure @safe void16 __simd(XMM opcode, void16 op1, void16 op2);
 
@@ -480,6 +502,7 @@ version (D_SIMD)
     /*****
     * For "store" operations of the form:
     *    op1 op= op2
+    * such as MOVLPS.
     * Returns:
     *    op2
     * These cannot be marked as pure, as semantic() doesn't check them.
@@ -487,6 +510,7 @@ version (D_SIMD)
     @safe void16 __simd_sto(XMM opcode, void16 op1, void16 op2);
     @safe void16 __simd_sto(XMM opcode, double op1, void16 op2); ///
     @safe void16 __simd_sto(XMM opcode, float op1, void16 op2);  ///
+    @safe void16 __simd_sto(XMM opcode, void16 op1, long op2); ///
 
     ///
     unittest
index 035bba5eb30fb5335427b5c8c4e869fb714fe3b0..2662fdb0fff9535489518c4260571c6c8ce4e773 100644 (file)
@@ -13,108 +13,13 @@ extern (C):
 import core.stdc.stdint;
 public import core.sys.dragonflybsd.sys.elf_common;
 
-alias uint16_t Elf32_Half;
-alias uint32_t Elf32_Word;
-alias int32_t  Elf32_Sword;
 alias uint64_t Elf32_Lword;
-alias uint32_t Elf32_Addr;
-alias uint32_t Elf32_Off;
 alias Elf32_Word Elf32_Hashelt;
 alias Elf32_Word Elf32_Size;
 alias Elf32_Sword Elf32_Ssize;
 
-struct Elf32_Ehdr
-{
-    char[EI_NIDENT] e_ident = 0;
-    Elf32_Half    e_type;
-    Elf32_Half    e_machine;
-    Elf32_Word    e_version;
-    Elf32_Addr    e_entry;
-    Elf32_Off     e_phoff;
-    Elf32_Off     e_shoff;
-    Elf32_Word    e_flags;
-    Elf32_Half    e_ehsize;
-    Elf32_Half    e_phentsize;
-    Elf32_Half    e_phnum;
-    Elf32_Half    e_shentsize;
-    Elf32_Half    e_shnum;
-    Elf32_Half    e_shstrndx;
-}
-
-struct Elf32_Shdr
-{
-    Elf32_Word    sh_name;
-    Elf32_Word    sh_type;
-    Elf32_Word    sh_flags;
-    Elf32_Addr    sh_addr;
-    Elf32_Off     sh_offset;
-    Elf32_Word    sh_size;
-    Elf32_Word    sh_link;
-    Elf32_Word    sh_info;
-    Elf32_Word    sh_addralign;
-    Elf32_Word    sh_entsize;
-}
-
-struct Elf32_Phdr
-{
-    Elf32_Word    p_type;
-    Elf32_Off     p_offset;
-    Elf32_Addr    p_vaddr;
-    Elf32_Addr    p_paddr;
-    Elf32_Word    p_filesz;
-    Elf32_Word    p_memsz;
-    Elf32_Word    p_flags;
-    Elf32_Word    p_align;
-}
-
-struct Elf32_Dyn
-{
-  Elf32_Sword   d_tag;
-  union _d_un
-  {
-      Elf32_Word d_val;
-      Elf32_Addr d_ptr;
-  } _d_un d_un;
-}
-
-struct Elf32_Rel
-{
-    Elf32_Addr    r_offset;
-    Elf32_Word    r_info;
-}
-
-struct Elf32_Rela
-{
-    Elf32_Addr    r_offset;
-    Elf32_Word    r_info;
-    Elf32_Sword   r_addend;
-}
-
-extern (D) pure @safe
-{
-    auto ELF32_R_SYM(V)(V val) { return val >> 8; }
-    auto ELF32_R_TYPE(V)(V val) { return val & 0xff; }
-    auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); }
-}
-
 alias Elf_Note Elf32_Nhdr;
 
-struct Elf32_Move
-{
-    Elf32_Lword   m_value;
-    Elf32_Word    m_info;
-    Elf32_Word    m_poffset;
-    Elf32_Half    m_repeat;
-    Elf32_Half    m_stride;
-}
-
-extern (D) pure
-{
-    auto ELF32_M_SYM(I)(I info) @safe { return info >> 8; }
-    auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; }
-    auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; }
-}
-
 struct Elf32_Cap
 {
     Elf32_Word    c_tag;
@@ -125,63 +30,7 @@ struct Elf32_Cap
     } _c_un c_un;
 }
 
-struct Elf32_Sym
-{
-    Elf32_Word    st_name;
-    Elf32_Addr    st_value;
-    Elf32_Word    st_size;
-    ubyte st_info;
-    ubyte st_other;
-    Elf32_Half st_shndx;
-}
-
-extern (D) pure
-{
-    auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
-    auto ELF32_ST_TYPE(T)(T val) @safe { return val & 0xf; }
-    auto ELF32_ST_INFO(B, T)(B bind, T type) @safe { return (bind << 4) + (type & 0xf); }
-    auto ELF32_ST_VISIBILITY(O)(O o) @safe { return o & 0x03; }
-}
-
-struct Elf32_Verdef
-{
-    Elf32_Half    vd_version;
-    Elf32_Half    vd_flags;
-    Elf32_Half    vd_ndx;
-    Elf32_Half    vd_cnt;
-    Elf32_Word    vd_hash;
-    Elf32_Word    vd_aux;
-    Elf32_Word    vd_next;
-}
-
-struct Elf32_Verdaux
-{
-    Elf32_Word    vda_name;
-    Elf32_Word    vda_next;
-}
-
-struct Elf32_Verneed
-{
-    Elf32_Half    vn_version;
-    Elf32_Half    vn_cnt;
-    Elf32_Word    vn_file;
-    Elf32_Word    vn_aux;
-    Elf32_Word    vn_next;
-}
-
-struct Elf32_Vernaux
-{
-    Elf32_Word    vna_hash;
-    Elf32_Half    vna_flags;
-    Elf32_Half    vna_other;
-    Elf32_Word    vna_name;
-    Elf32_Word    vna_next;
-}
-
-alias Elf32_Half Elf32_Versym;
-
-struct Elf32_Syminfo
+extern (D)
 {
-    Elf32_Half si_boundto;
-    Elf32_Half si_flags;
+    auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; }
 }
index f7d9247e0e3b624a3523a69a70525de640b8c5c9..6431bd2347a1b5e0f2008a1b066280fafb1ec5c0 100644 (file)
@@ -13,91 +13,13 @@ extern (C):
 import core.stdc.stdint;
 public import core.sys.dragonflybsd.sys.elf_common;
 
-alias uint16_t Elf64_Half;
-alias uint32_t Elf64_Word;
-alias int32_t  Elf64_Sword;
 alias uint64_t Elf64_Lword;
-alias uint64_t Elf64_Xword;
-alias int64_t  Elf64_Sxword;
-alias uint64_t Elf64_Addr;
-alias uint64_t Elf64_Off;
 alias Elf64_Word Elf64_Hashelt;
 alias Elf64_Xword Elf64_Size;
 alias Elf64_Sxword Elf64_Ssize;
 
-struct Elf64_Ehdr
-{
-    char[EI_NIDENT] e_ident = 0;
-    Elf64_Half    e_type;
-    Elf64_Half    e_machine;
-    Elf64_Word    e_version;
-    Elf64_Addr    e_entry;
-    Elf64_Off     e_phoff;
-    Elf64_Off     e_shoff;
-    Elf64_Word    e_flags;
-    Elf64_Half    e_ehsize;
-    Elf64_Half    e_phentsize;
-    Elf64_Half    e_phnum;
-    Elf64_Half    e_shentsize;
-    Elf64_Half    e_shnum;
-    Elf64_Half    e_shstrndx;
-}
-
-struct Elf64_Shdr
-{
-    Elf64_Word    sh_name;
-    Elf64_Word    sh_type;
-    Elf64_Xword   sh_flags;
-    Elf64_Addr    sh_addr;
-    Elf64_Off     sh_offset;
-    Elf64_Xword   sh_size;
-    Elf64_Word    sh_link;
-    Elf64_Word    sh_info;
-    Elf64_Xword   sh_addralign;
-    Elf64_Xword   sh_entsize;
-}
-
-struct Elf64_Phdr
-{
-    Elf64_Word    p_type;
-    Elf64_Word    p_flags;
-    Elf64_Off     p_offset;
-    Elf64_Addr    p_vaddr;
-    Elf64_Addr    p_paddr;
-    Elf64_Xword   p_filesz;
-    Elf64_Xword   p_memsz;
-    Elf64_Xword   p_align;
-}
-
-struct Elf64_Dyn
-{
-  Elf64_Sxword  d_tag;
-  union _d_un
-  {
-      Elf64_Xword d_val;
-      Elf64_Addr d_ptr;
-  } _d_un d_un;
-}
-
-struct Elf64_Rel
-{
-    Elf64_Addr    r_offset;
-    Elf64_Xword   r_info;
-}
-
-struct Elf64_Rela
-{
-    Elf64_Addr    r_offset;
-    Elf64_Xword   r_info;
-    Elf64_Sxword  r_addend;
-}
-
 extern (D) pure
 {
-    auto ELF64_R_SYM(I)(I i) @safe { return i >> 32; }
-    auto ELF64_R_TYPE(I)(I i) @safe { return i & 0xffffffff; }
-    auto ELF64_R_INFO(S, T)(S sym, T type) @safe { return (sym << 32) + (type & 0xffffffff); }
-
     auto ELF64_R_TYPE_DATA(I)(I i) { return (cast(Elf64_Xword) i << 32) >> 40; }
     auto ELF64_R_TYPE_ID(I)(I i) { return (cast(Elf64_Xword) i << 56 ) >> 56; }
     auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; }
@@ -105,22 +27,6 @@ extern (D) pure
 
 alias Elf_Note Elf64_Nhdr;
 
-struct Elf64_Move
-{
-    Elf64_Lword   m_value;
-    Elf64_Xword   m_info;
-    Elf64_Xword   m_poffset;
-    Elf64_Half    m_repeat;
-    Elf64_Half    m_stride;
-}
-
-extern (D) pure
-{
-    auto ELF64_M_SYM(I)(I info) @safe { return info >> 8; }
-    auto ELF64_M_SIZE(I)(I info) { return cast(ubyte)info; }
-    auto ELF64_M_INFO(S, SZ)(S sym, SZ size) @safe { return (sym << 8) + cast(ubyte)size; }
-}
-
 struct Elf64_Cap
 {
     Elf64_Xword   c_tag;
@@ -131,63 +37,7 @@ struct Elf64_Cap
     } _c_un c_un;
 }
 
-struct Elf64_Sym
-{
-    Elf64_Word    st_name;
-    ubyte st_info;
-    ubyte st_other;
-    Elf64_Half st_shndx;
-    Elf64_Addr    st_value;
-    Elf64_Xword   st_size;
-}
-
-extern (D) pure
-{
-    auto ELF64_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
-    auto ELF64_ST_TYPE(T)(T val) @safe { return val & 0xf; }
-    auto ELF64_ST_INFO(B, T)(B bind, T type) @safe { return (bind << 4) + (type & 0xf); }
-    auto ELF64_ST_VISIBILITY(O)(O o) @safe { return o & 0x03; }
-}
-
-struct Elf64_Verdef
-{
-    Elf64_Half    vd_version;
-    Elf64_Half    vd_flags;
-    Elf64_Half    vd_ndx;
-    Elf64_Half    vd_cnt;
-    Elf64_Word    vd_hash;
-    Elf64_Word    vd_aux;
-    Elf64_Word    vd_next;
-}
-
-struct Elf64_Verdaux
-{
-    Elf64_Word    vda_name;
-    Elf64_Word    vda_next;
-}
-
-struct Elf64_Verneed
-{
-    Elf64_Half    vn_version;
-    Elf64_Half    vn_cnt;
-    Elf64_Word    vn_file;
-    Elf64_Word    vn_aux;
-    Elf64_Word    vn_next;
-}
-
-struct Elf64_Vernaux
-{
-    Elf64_Word    vna_hash;
-    Elf64_Half    vna_flags;
-    Elf64_Half    vna_other;
-    Elf64_Word    vna_name;
-    Elf64_Word    vna_next;
-}
-
-alias Elf64_Half Elf64_Versym;
-
-struct Elf64_Syminfo
+extern (D)
 {
-    Elf64_Half si_boundto;
-    Elf64_Half si_flags;
+    auto ELF64_ST_VISIBILITY(O)(O o) { return o & 0x03; }
 }
index eef6a89e7a3c4dd802bb3163e4a470b73294c419..90e5861a6acdc7da4f2e452c07609c12872d4a21 100644 (file)
@@ -11,6 +11,7 @@ version (DragonFlyBSD):
 extern (C):
 
 import core.stdc.stdint;
+public import core.sys.elf;
 
 struct Elf_Note
 {
@@ -27,60 +28,7 @@ struct Elf_GNU_Hash_Header
     uint32_t      gh_shift2;
 }
 
-enum EI_MAG0 =         0;
-enum EI_MAG1 =         1;
-enum EI_MAG2 =         2;
-enum EI_MAG3 =         3;
-enum EI_CLASS =        4;
-enum EI_DATA =         5;
-enum EI_VERSION =      6;
-enum EI_OSABI =        7;
-enum EI_ABIVERSION =   8;
 enum OLD_EI_BRAND =    8;
-enum EI_PAD =          9;
-enum EI_NIDENT =       16;
-
-enum ELFMAG0 =         0x7f;
-enum ELFMAG1 =         'E';
-enum ELFMAG2 =         'L';
-enum ELFMAG3 =         'F';
-enum ELFMAG =          "\177ELF";
-enum SELFMAG =         4;
-
-enum EV_NONE =         0;
-enum EV_CURRENT =      1;
-
-enum ELFCLASSNONE =    0;
-enum ELFCLASS32 =      1;
-enum ELFCLASS64 =      2;
-
-enum ELFDATANONE =     0;
-enum ELFDATA2LSB =     1;
-enum ELFDATA2MSB =     2;
-
-enum ELFOSABI_NONE =           0;
-enum ELFOSABI_SYSV =           0;
-enum ELFOSABI_HPUX =           1;
-enum ELFOSABI_NETBSD =         2;
-enum ELFOSABI_LINUX =          3;
-enum ELFOSABI_HURD  =          4;
-enum ELFOSABI_86OPEN =         5;
-enum ELFOSABI_SOLARIS =        6;
-enum ELFOSABI_AIX =            7;
-enum ELFOSABI_MONTEREY =       7;
-enum ELFOSABI_IRIX =           8;
-enum ELFOSABI_FREEBSD =        9;
-enum ELFOSABI_TRU64 =          10;
-enum ELFOSABI_MODESTO =        11;
-enum ELFOSABI_OPENBSD =        12;
-enum ELFOSABI_OPENVMS =        13;
-enum ELFOSABI_NSK =            14;
-enum ELFOSABI_AROS =           15;
-enum ELFOSABI_ARM =            97;
-enum ELFOSABI_STANDALONE =     255;
-
-// just a pointer
-enum ELFOSABI_DRAGONFLYBSD =   ELFOSABI_NONE;
 
 extern (D) pure @safe
 {
@@ -90,587 +38,44 @@ extern (D) pure @safe
                                     ehdr.e_ident[EI_MAG3] == ELFMAG3; }
 }
 
-enum ET_NONE =         0;
-enum ET_REL =          1;
-enum ET_EXEC =         2;
-enum ET_DYN =          3;
-enum ET_CORE =         4;
-enum ET_LOOS =         0xfe00;
-enum ET_HIOS =         0xfeff;
-enum ET_LOPROC =       0xff00;
-enum ET_HIPROC =       0xffff;
-
-enum EM_NONE =          0;
-enum EM_M32 =           1;
-enum EM_SPARC =         2;
-enum EM_386 =           3;
-enum EM_68K =           4;
-enum EM_88K =           5;
-enum EM_860 =           7;
-enum EM_MIPS =          8;
-enum EM_S370 =          9;
-enum EM_MIPS_RS3_LE =  10;
-enum EM_PARISC =       15;
-enum EM_VPP500 =       17;
-enum EM_SPARC32PLUS =  18;
-enum EM_960 =          19;
-enum EM_PPC =          20;
-enum EM_PPC64 =        21;
-enum EM_S390 =         22;
-enum EM_V800 =         36;
-enum EM_FR20 =         37;
-enum EM_RH32 =         38;
-enum EM_RCE =          39;
-enum EM_ARM =          40;
-enum EM_SH =           42;
-enum EM_SPARCV9 =      43;
-enum EM_TRICORE =      44;
-enum EM_ARC =          45;
-enum EM_H8_300 =       46;
-enum EM_H8_300H =      47;
-enum EM_H8S =          48;
-enum EM_H8_500 =       49;
-enum EM_IA_64 =        50;
-enum EM_MIPS_X =       51;
-enum EM_COLDFIRE =     52;
-enum EM_68HC12 =       53;
-enum EM_MMA =          54;
-enum EM_PCP =          55;
-enum EM_NCPU =         56;
-enum EM_NDR1 =         57;
-enum EM_STARCORE =     58;
-enum EM_ME16 =         59;
-enum EM_ST100 =        60;
-enum EM_TINYJ =        61;
-enum EM_X86_64 =       62;
-enum EM_AMD64 =        62;
-enum EM_PDSP =         63;
-enum EM_FX66 =         66;
-enum EM_ST9PLUS =      67;
-enum EM_ST7 =          68;
-enum EM_68HC16 =       69;
-enum EM_68HC11 =       70;
-enum EM_68HC08 =       71;
-enum EM_68HC05 =       72;
-enum EM_SVX =          73;
-enum EM_ST19 =         74;
-enum EM_VAX =          75;
-enum EM_CRIS =         76;
-enum EM_JAVELIN =      77;
-enum EM_FIREPATH =     78;
-enum EM_ZSP =          79;
-enum EM_MMIX =         80;
-enum EM_HUANY =        81;
-enum EM_PRISM =        82;
-enum EM_AVR =          83;
-enum EM_FR30 =         84;
-enum EM_D10V =         85;
-enum EM_D30V =         86;
-enum EM_V850 =         87;
-enum EM_M32R =         88;
-enum EM_MN10300 =      89;
-enum EM_MN10200 =      90;
-enum EM_PJ =           91;
-enum EM_OPENRISC =     92;
-enum EM_ARC_A5 =       93;
-enum EM_XTENSA =       94;
-enum EM_VIDEOCORE =    95;
-enum EM_TMM_GPP =      96;
-enum EM_NS32K =        97;
-enum EM_TPC =          98;
-enum EM_SNP1K =        99;
-enum EM_ST200 =       100;
-enum EM_IP2K =        101;
-enum EM_MAX =         102;
-enum EM_CR =          103;
-enum EM_F2MC16 =      104;
-enum EM_MSP430 =      105;
-enum EM_BLACKFIN =    106;
-enum EM_SE_C33 =      107;
-enum EM_SEP =         108;
-enum EM_ARCA =        109;
-enum EM_UNICORE =     110;
-enum EM_DXP =         112;
-enum EM_ALTERA_NIOS2 =113;
-enum EM_CRX =         114;
-enum EM_XGATE =       115;
-enum EM_C166  =       116;
-enum EM_M16C  =       117;
-enum EM_DSPIC30F =    118;
-enum EM_CE =          119;
-enum EM_M32C  =       120;
-enum EM_res121 =      121;
-enum EM_res122 =      122;
-enum EM_res123 =      123;
-enum EM_res124 =      124;
-enum EM_res125 =      125;
-enum EM_res126 =      126;
-enum EM_res127 =      127;
-enum EM_res128 =      128;
-enum EM_res129 =      129;
-enum EM_res130 =      130;
-enum EM_TSK3000 =     131;
-enum EM_RS08  =       132;
-enum EM_res133 =      133;
-enum EM_ECOG2 =       134;
-enum EM_SCORE =       135;
-enum EM_SCORE7 =      135;
-enum EM_DSP24 =       136;
-enum EM_VIDEOCORE3 =  137;
-enum EM_LATTICEMICO32 = 138;
-enum EM_SE_C17 =      139;
-enum EM_TI_C6000 =    140;
-enum EM_TI_C2000 =    141;
-enum EM_TI_C5500 =    142;
-enum EM_res143 =      143;
-enum EM_res144 =      144;
-enum EM_res145 =      145;
-enum EM_res146 =      146;
-enum EM_res147 =      147;
-enum EM_res148 =      148;
-enum EM_res149 =      149;
-enum EM_res150 =      150;
-enum EM_res151 =      151;
-enum EM_res152 =      152;
-enum EM_res153 =      153;
-enum EM_res154 =      154;
-enum EM_res155 =      155;
-enum EM_res156 =      156;
-enum EM_res157 =      157;
-enum EM_res158 =      158;
-enum EM_res159 =      159;
-enum EM_MMDSP_PLUS =  160;
-enum EM_CYPRESS_M8C = 161;
-enum EM_R32C  =       162;
-enum EM_TRIMEDIA =    163;
-enum EM_QDSP6 =       164;
-enum EM_8051  =       165;
-enum EM_STXP7X =      166;
-enum EM_NDS32 =       167;
-enum EM_ECOG1 =       168;
-enum EM_ECOG1X =      168;
-enum EM_MAXQ30 =      169;
-enum EM_XIMO16 =      170;
-enum EM_MANIK =       171;
-enum EM_CRAYNV2 =     172;
-enum EM_RX =          173;
-enum EM_METAG =       174;
-enum EM_MCST_ELBRUS = 175;
-enum EM_ECOG16 =      176;
-enum EM_CR16  =       177;
-enum EM_ETPU  =       178;
-enum EM_SLE9X =       179;
-enum EM_L1OM  =       180;
-enum EM_K1OM  =       181;
-enum EM_INTEL182 =    182;
-enum EM_res183 =      183;
-enum EM_res184 =      184;
-enum EM_AVR32 =       185;
-enum EM_STM8  =       186;
-enum EM_TILE64 =      187;
-enum EM_TILEPRO =     188;
-enum EM_MICROBLAZE =  189;
-enum EM_CUDA  =       190;
-enum EM_TILEGX =      191;
-
 enum EM_486 =           6;
 enum EM_MIPS_RS4_BE =  10;
 enum EM_ALPHA_STD =    41;
-enum EM_ALPHA =    0x9026;
-
-enum SHN_UNDEF =       0;
-enum SHN_LORESERVE =   0xff00;
-enum SHN_LOPROC =      0xff00;
-enum SHN_HIPROC =      0xff1f;
-enum SHN_LOOS =        0xff20;
-enum SHN_HIOS =        0xff3f;
-enum SHN_ABS =         0xfff1;
-enum SHN_COMMON =      0xfff2;
-enum SHN_XINDEX =      0xffff;
-enum SHN_HIRESERVE =   0xffff;
-
-enum PT_NULL =         0;
-enum PT_LOAD =         1;
-enum PT_DYNAMIC =      2;
-enum PT_INTERP =       3;
-enum PT_NOTE =         4;
-enum PT_SHLIB =        5;
-enum PT_PHDR =         6;
-enum PT_TLS =          7;
-enum PT_LOOS =         0x60000000;
-enum PT_HIOS =         0x6fffffff;
-enum PT_LOPROC =       0x70000000;
-enum PT_HIPROC =       0x7fffffff;
 
-enum PT_GNU_EH_FRAME =  PT_LOOS + 0x474e550; /* Frame unwind information */
-enum PT_SUNW_EH_FRAME = PT_GNU_EH_FRAME;     /* Solaris uses the same value */
-enum PT_GNU_STACK =     PT_LOOS + 0x474e551; /* Stack flags */
-enum PT_GNU_RELRO =     PT_LOOS + 0x474e552;  /* Read-only after relocation */
-
-enum PF_X =            0x1;
-enum PF_W =            0x2;
-enum PF_R =            0x4;
-enum PF_MASKOS =       0x0ff00000;
-enum PF_MASKPROC =     0xf0000000;
-
-enum PN_XNUM =         0xffff;
-
-enum SHT_NULL =          0;
-enum SHT_PROGBITS =      1;
-enum SHT_SYMTAB =        2;
-enum SHT_STRTAB =        3;
-enum SHT_RELA =          4;
-enum SHT_HASH =          5;
-enum SHT_DYNAMIC =       6;
-enum SHT_NOTE =          7;
-enum SHT_NOBITS =        8;
-enum SHT_REL =           9;
-enum SHT_SHLIB =         10;
-enum SHT_DYNSYM =        11;
-
-enum SHT_INIT_ARRAY =    14;
-enum SHT_FINI_ARRAY =    15;
-enum SHT_PREINIT_ARRAY = 16;
-enum SHT_GROUP =         17;
-enum SHT_SYMTAB_SHNDX =  18;
-
-enum SHT_LOOS =          0x60000000;
-enum SHT_LOSUNW =        0x6ffffff4;
+enum PT_SUNW_EH_FRAME = PT_GNU_EH_FRAME;
 
 enum SHT_GNU_INCREMENTAL_INPUTS =  0x6fff4700;
-enum SHT_GNU_ATTRIBUTES =       0x6ffffff5;
-enum SHT_GNU_HASH =             0x6ffffff6;
-enum SHT_GNU_LIBLIST =          0x6ffffff7;
 
-//enum SHT_SUNW_dof =      0x6ffffff4;
-//enum SHT_SUNW_cap =      0x6ffffff5;
-//enum SHT_SUNW_SIGNATURE = 0x6ffffff6;
 enum SHT_SUNW_verdef =   0x6ffffffd;
 enum SHT_SUNW_verneed =  0x6ffffffe;
 enum SHT_SUNW_versym =   0x6fffffff;
 
-enum SHT_GNU_verdef =    SHT_SUNW_verdef;
-enum SHT_GNU_verneed =   SHT_SUNW_verneed;
-enum SHT_GNU_versym =    SHT_SUNW_versym;
-
-enum SHT_LOPROC =        0x70000000;
-enum SHT_HIPROC =        0x7fffffff;
-enum SHT_LOUSER =        0x80000000;
-enum SHT_HIUSER =        0x8fffffff;
-
-/*
-enum SHT_GNU_HASH =      0x6ffffff6;
-enum SHT_SUNW_ANNOTATE = 0x6ffffff7;
-enum SHT_SUNW_DEBUGSTR = 0x6ffffff8;
-enum SHT_SUNW_DEBUG =    0x6ffffff9;
-enum SHT_SUNW_move =     0x6ffffffa;
-enum SHT_SUNW_COMDAT =   0x6ffffffb;
-enum SHT_SUNW_syminfo =  0x6ffffffc;
-enum SHT_HISUNW =        0x6fffffff;
-enum SHT_HIOS =          0x6fffffff;
-enum SHT_AMD64_UNWIND =  0x70000001;
-enum SHT_ARM_EXIDX =     0x70000001;
-enum SHT_ARM_PREEMPTMAP = 0x70000002;
-enum SHT_ARM_ATTRIBUTES = 0x70000003;
-enum SHT_ARM_DEBUGOVERLAY = 0x70000004;
-enum SHT_ARM_OVERLAYSECTION = 0x70000005;
-enum SHT_MIPS_REGINFO =  0x70000006;
-enum SHT_MIPS_OPTIONS =  0x7000000d;
-enum SHT_MIPS_DWARF =    0x7000001e;
-*/
-
-enum SHF_WRITE =            (1 << 0);
-enum SHF_ALLOC =            (1 << 1);
-enum SHF_EXECINSTR =        (1 << 2);
-enum SHF_MERGE =            (1 << 4);
-enum SHF_STRINGS =          (1 << 5);
-enum SHF_INFO_LINK =        (1 << 6);
-enum SHF_LINK_ORDER =       (1 << 7);
-enum SHF_OS_NONCONFORMING = (1 << 8);
-enum SHF_GROUP =            (1 << 9);
-enum SHF_TLS =              (1 << 10);
-enum SHF_COMPRESSED =       (1 << 11);
-
-enum SHF_MASKOS =           0x0ff00000;
-enum SHF_MASKPROC =         0xf0000000;
-
 enum NT_PRSTATUS =     1;
 enum NT_FPREGSET =     2;
 enum NT_PRPSINFO =     3;
 enum NT_TASKSTRUCT =   4;
 enum NT_AUXV =         6;
 
-/*
-enum NT_THRMISC =      7;
-enum NT_PROCSTAT_PROC = 8;
-enum NT_PROCSTAT_FILES = 9;
-enum NT_PROCSTAT_VMMAP = 10;
-enum NT_PROCSTAT_GROUPS = 11;
-enum NT_PROCSTAT_UMASK = 12;
-enum NT_PROCSTAT_RLIMIT = 13;
-enum NT_PROCSTAT_OSREL = 14;
-enum NT_PROCSTAT_PSSTRINGS = 15;
-enum NT_PROCSTAT_AUXV = 16;
-*/
-
-enum STN_UNDEF =       0;
-
-enum STB_LOCAL =       0;
-enum STB_GLOBAL =      1;
-enum STB_WEAK =        2;
-enum STB_NUM =         3;
-enum STB_LOOS =        10;
-enum STB_HIOS =        12;
-enum STB_LOPROC =      13;
-enum STB_HIPROC =      15;
-
-enum STT_NOTYPE =      0;
-enum STT_OBJECT =      1;
-enum STT_FUNC =        2;
-enum STT_SECTION =     3;
-enum STT_FILE =        4;
-enum STT_COMMON =      5;
-enum STT_TLS =         6;
-enum STT_NUM =         7;
-enum STT_LOOS =        10;
-enum STT_GNU_IFUNC =   10;
-enum STT_HIOS =        12;
-enum STT_LOPROC =      13;
-enum STT_HIPROC =      15;
-
-enum STV_DEFAULT =     0;
-enum STV_INTERNAL =    1;
-enum STV_HIDDEN =      2;
-enum STV_PROTECTED =   3;
-/*
-enum STV_EXPORTED =    4;
-enum STV_SINGLETON =   5;
-enum STV_ELIMINATE =   6;
-*/
-
-enum DT_NULL =         0;
-enum DT_NEEDED =       1;
-enum DT_PLTRELSZ =     2;
-enum DT_PLTGOT =       3;
-enum DT_HASH =         4;
-enum DT_STRTAB =       5;
-enum DT_SYMTAB =       6;
-enum DT_RELA =         7;
-enum DT_RELASZ =       8;
-enum DT_RELAENT =      9;
-enum DT_STRSZ =        10;
-enum DT_SYMENT =       11;
-enum DT_INIT =         12;
-enum DT_FINI =         13;
-enum DT_SONAME =       14;
-enum DT_RPATH =        15;
-enum DT_SYMBOLIC =     16;
-enum DT_REL =          17;
-enum DT_RELSZ =        18;
-enum DT_RELENT =       19;
-enum DT_PLTREL =       20;
-enum DT_DEBUG =        21;
-enum DT_TEXTREL =      22;
-enum DT_JMPREL =       23;
-enum DT_BIND_NOW =     24;
-enum DT_INIT_ARRAY =   25;
-enum DT_FINI_ARRAY =   26;
-enum DT_INIT_ARRAYSZ = 27;
-enum DT_FINI_ARRAYSZ = 28;
-enum DT_RUNPATH =      29;
-enum DT_FLAGS =        30;
-
-enum DT_ENCODING =     32;
-enum DT_PREINIT_ARRAY = 32;
-enum DT_PREINIT_ARRAYSZ = 33;
-//enum DT_MAXPOSTAGS =   34;
-enum DT_LOOS =         0x6000000d;
-enum DT_HIOS =         0x6ffff000;
-/*
-enum DT_SUNW_AUXILIARY = 0x6000000d;
-enum DT_SUNW_RTLDINF = 0x6000000e;
-enum DT_SUNW_FILTER =  0x6000000f;
-enum DT_SUNW_CAP =     0x60000010;
-*/
-
-enum DT_VALRNGLO =     0x6ffffd00;
-enum DT_GNU_PRELINKED = 0x6ffffdf5;
-enum DT_GNU_CONFLICTSZ =0x6ffffdf6;
-enum DT_GNU_LIBLISTSZ = 0x6ffffdf7;
-enum DT_CHECKSUM =     0x6ffffdf8;
-enum DT_PLTPADSZ =     0x6ffffdf9;
-enum DT_MOVEENT =      0x6ffffdfa;
-enum DT_MOVESZ =       0x6ffffdfb;
-enum DT_FEATURE_1 =    0x6ffffdfc;
-enum DT_POSFLAG_1 =    0x6ffffdfd;
-enum DT_SYMINSZ =      0x6ffffdfe;
-enum DT_SYMINENT =     0x6ffffdff;
-enum DT_VALRNGHI =     0x6ffffdff;
-enum DT_ADDRRNGLO =    0x6ffffe00;
-enum DT_GNU_HASH =     0x6ffffef5;
-enum DT_TLSDESC_PLT =  0x6ffffef6;
-enum DT_TLSDESC_GOT =  0x6ffffef7;
-enum DT_GNU_CONFLICT = 0x6ffffef8;
-enum DT_GNU_LIBLIST =  0x6ffffef9;
-enum DT_CONFIG =       0x6ffffefa;
-enum DT_DEPAUDIT =     0x6ffffefb;
-enum DT_AUDIT =        0x6ffffefc;
-enum DT_PLTPAD =       0x6ffffefd;
-enum DT_MOVETAB =      0x6ffffefe;
-enum DT_SYMINFO =      0x6ffffeff;
-enum DT_ADDRRNGHI =    0x6ffffeff;
-enum DT_RELACOUNT =    0x6ffffff9;
-enum DT_RELCOUNT =     0x6ffffffa;
-enum DT_FLAGS_1 =      0x6ffffffb;
-enum DT_VERDEF =       0x6ffffffc;
-enum DT_VERDEFNUM =    0x6ffffffd;
-enum DT_VERNEED =      0x6ffffffe;
-enum DT_VERNEEDNUM =   0x6fffffff;
-enum DT_VERSYM =       0x6ffffff0;
-enum DT_LOPROC =       0x70000000;
-//enum DT_DEPRECATED_SPARC_REGISTER = 0x7000001;
-enum DT_AUXILIARY =    0x7ffffffd;
 enum DT_USED =         0x7ffffffe;
-enum DT_FILTER =       0x7fffffff;
-enum DT_HIPROC =       0x7fffffff;
-
-enum DTF_1_PARINIT =   0x00000001;
-enum DTF_1_CONFEXP =   0x00000002;
-
-enum DF_P1_LAZYLOAD =  0x00000001;
-enum DF_P1_GROUPPERM=  0x00000002;
 
-enum DF_1_NOW =        0x00000001;
 enum DF_1_BIND_NOW =   0x00000001;
-enum DF_1_GLOBAL =     0x00000002;
-enum DF_1_GROUP =      0x00000004;
-enum DF_1_NODELETE =   0x00000008;
-enum DF_1_LOADFLTR =   0x00000010;
-enum DF_1_INITFIRST =  0x00000020;
-enum DF_1_NOOPEN =     0x00000040;
-enum DF_1_ORIGIN =     0x00000080;
-enum DF_1_DIRECT =     0x00000100;
-enum DF_1_TRANS =      0x00000200;
-enum DF_1_INTERPOSE =  0x00000400;
-enum DF_1_NODEFLIB =   0x00000800;
-enum DF_1_NODUMP =     0x00001000;
-enum DF_1_CONLFAT =    0x00002000;
 
-enum DF_ORIGIN =       0x00000001;
-enum DF_SYMBOLIC =     0x00000002;
-enum DF_TEXTREL =      0x00000004;
-enum DF_BIND_NOW =     0x00000008;
-enum DF_STATIC_TLS =   0x00000010;
-
-enum VER_DEF_NONE =    0;
-enum VER_DEF_CURRENT = 1;
 alias VER_NDX VER_DEF_IDX;
 
-enum VER_FLG_BASE =    0x1;
-enum VER_FLG_WEAK =    0x2;
 enum VER_FLG_INFO =    0x4;
 
-enum VER_NDX_LOCAL =           0;
-enum VER_NDX_GLOBAL =          1;
 enum VER_NDX_GIVEN =           2;
 enum VER_NDX_HIDDEN =      32768;
+
 extern (D) pure @safe
 {
     auto VER_NDX(V)(V v) { return v & ~(1u << 15); }
 }
 
-enum VER_NEED_NONE   = 0;
-enum VER_NEED_CURRENT = 1;
 enum VER_NEED_WEAK =    32768;
 enum VER_NEED_HIDDEN = VER_NDX_HIDDEN;
 alias VER_NDX VER_NEED_IDX;
 
-/*
-enum CA_SUNW_NULL =    0;
-enum CA_SUNW_HW_1 =    1;
-enum CA_SUNW_SF_1 =    2;
-*/
-
 enum VERSYM_HIDDEN =   0x8000;
 enum VERSYM_VERSION =  0x7fff;
 enum ELF_VER_CHR =     '@';
-
-enum SYMINFO_BT_SELF =         0xffff;
-enum SYMINFO_BT_PARENT =       0xfffe;
-//enum SYMINFO_BT_NONE =         0xfffd;
-//enum SYMINFO_BT_EXTERN =       0xfffc;
-enum SYMINFO_BT_LOWRESERVE =   0xff00;
-
-enum SYMINFO_FLG_DIRECT =      0x0001;
-enum SYMINFO_FLG_PASSTHRU =    0x0002;
-enum SYMINFO_FLG_COPY =        0x0004;
-enum SYMINFO_FLG_LAZYLOAD =    0x0008;
-//enum SYMINFO_FLG_DIRECTBIND =  0x0010;
-//enum SYMINFO_FLG_NOEXTDIRECT = 0x0020;
-//enum SYMINFO_FLG_FILTER =      0x0002;
-//enum SYMINFO_FLG_AUXILIARY =   0x0040;
-
-enum SYMINFO_NONE =            0;
-enum SYMINFO_CURRENT =         1;
-enum SYMINFO_NUM =             2;
-
-enum GRP_COMDAT =              0x1;
-
-enum R_386_NONE =               0;
-enum R_386_32 =                 1;
-enum R_386_PC32 =               2;
-enum R_386_GOT32 =              3;
-enum R_386_PLT32 =              4;
-enum R_386_COPY =               5;
-enum R_386_GLOB_DAT =           6;
-enum R_386_JMP_SLOT =           7;
-enum R_386_RELATIVE =           8;
-enum R_386_GOTOFF =             9;
-enum R_386_GOTPC =              10;
-enum R_386_TLS_TPOFF =          14;
-enum R_386_TLS_IE =             15;
-enum R_386_TLS_GOTIE =          16;
-enum R_386_TLS_LE =             17;
-enum R_386_TLS_GD =             18;
-enum R_386_TLS_LDM =            19;
-enum R_386_TLS_GD_32 =          24;
-enum R_386_TLS_GD_PUSH =        25;
-enum R_386_TLS_GD_CALL =        26;
-enum R_386_TLS_GD_POP =         27;
-enum R_386_TLS_LDM_32 =         28;
-enum R_386_TLS_LDM_PUSH =       29;
-enum R_386_TLS_LDM_CALL =       30;
-enum R_386_TLS_LDM_POP =        31;
-enum R_386_TLS_LDO_32 =         32;
-enum R_386_TLS_IE_32 =          33;
-enum R_386_TLS_LE_32 =          34;
-enum R_386_TLS_DTPMOD32 =       35;
-enum R_386_TLS_DTPOFF32 =       36;
-enum R_386_TLS_TPOFF32 =        37;
-enum R_386_IRELATIVE =          42;
-
-enum R_X86_64_NONE =            0;
-enum R_X86_64_64 =              1;
-enum R_X86_64_PC32 =            2;
-enum R_X86_64_GOT32 =           3;
-enum R_X86_64_PLT32 =           4;
-enum R_X86_64_COPY =            5;
-enum R_X86_64_GLOB_DAT =        6;
-enum R_X86_64_JMP_SLOT =        7;
-enum R_X86_64_RELATIVE =        8;
-enum R_X86_64_GOTPCREL =        9;
-enum R_X86_64_32 =              10;
-enum R_X86_64_32S =             11;
-enum R_X86_64_16 =              12;
-enum R_X86_64_PC16 =            13;
-enum R_X86_64_8 =               14;
-enum R_X86_64_PC8 =             15;
-enum R_X86_64_DTPMOD64 =        16;
-enum R_X86_64_DTPOFF64 =        17;
-enum R_X86_64_TPOFF64 =         18;
-enum R_X86_64_TLSGD =           19;
-enum R_X86_64_TLSLD =           20;
-enum R_X86_64_DTPOFF32 =        21;
-enum R_X86_64_GOTTPOFF =        22;
-enum R_X86_64_TPOFF32 =         23;
-enum R_X86_64_IRELATIVE =       37;
diff --git a/libphobos/libdruntime/core/sys/elf/package.d b/libphobos/libdruntime/core/sys/elf/package.d
new file mode 100644 (file)
index 0000000..5de897a
--- /dev/null
@@ -0,0 +1,2532 @@
+/**
+ * D header file for standard ELF types, structures, and macros.
+ *
+ * $(LINK2 http://sourceware.org/git/?p=glibc.git;a=blob;f=elf/elf.h, glibc elf/elf.h)
+ */
+module core.sys.elf;
+
+extern (C):
+pure:
+nothrow:
+@system:
+
+import core.stdc.stdint;
+
+alias uint16_t Elf32_Half;
+alias uint16_t Elf64_Half;
+
+alias uint32_t Elf32_Word;
+alias int32_t  Elf32_Sword;
+alias uint32_t Elf64_Word;
+alias int32_t  Elf64_Sword;
+
+alias uint64_t Elf32_Xword;
+alias int64_t  Elf32_Sxword;
+alias uint64_t Elf64_Xword;
+alias int64_t  Elf64_Sxword;
+
+alias uint32_t Elf32_Addr;
+alias uint64_t Elf64_Addr;
+
+alias uint32_t Elf32_Off;
+alias uint64_t Elf64_Off;
+
+alias uint16_t Elf32_Section;
+alias uint16_t Elf64_Section;
+
+alias Elf32_Half Elf32_Versym;
+alias Elf64_Half Elf64_Versym;
+
+enum EI_NIDENT = 16;
+
+struct Elf32_Ehdr
+{
+    char[EI_NIDENT] e_ident = 0;
+    Elf32_Half    e_type;
+    Elf32_Half    e_machine;
+    Elf32_Word    e_version;
+    Elf32_Addr    e_entry;
+    Elf32_Off     e_phoff;
+    Elf32_Off     e_shoff;
+    Elf32_Word    e_flags;
+    Elf32_Half    e_ehsize;
+    Elf32_Half    e_phentsize;
+    Elf32_Half    e_phnum;
+    Elf32_Half    e_shentsize;
+    Elf32_Half    e_shnum;
+    Elf32_Half    e_shstrndx;
+}
+
+struct Elf64_Ehdr
+{
+    char[EI_NIDENT] e_ident = 0;
+    Elf64_Half    e_type;
+    Elf64_Half    e_machine;
+    Elf64_Word    e_version;
+    Elf64_Addr    e_entry;
+    Elf64_Off     e_phoff;
+    Elf64_Off     e_shoff;
+    Elf64_Word    e_flags;
+    Elf64_Half    e_ehsize;
+    Elf64_Half    e_phentsize;
+    Elf64_Half    e_phnum;
+    Elf64_Half    e_shentsize;
+    Elf64_Half    e_shnum;
+    Elf64_Half    e_shstrndx;
+}
+
+enum EI_MAG0 =         0;
+enum ELFMAG0 =         0x7f;
+
+enum EI_MAG1 =         1;
+enum ELFMAG1 =         'E';
+
+enum EI_MAG2 =         2;
+enum ELFMAG2 =         'L';
+
+enum EI_MAG3 =         3;
+enum ELFMAG3 =         'F';
+enum ELFMAG =          "\177ELF";
+enum SELFMAG =         4;
+
+enum EI_CLASS =        4;
+enum ELFCLASSNONE =    0;
+enum ELFCLASS32 =      1;
+enum ELFCLASS64 =      2;
+enum ELFCLASSNUM =     3;
+
+enum EI_DATA =         5;
+enum ELFDATANONE =     0;
+enum ELFDATA2LSB =     1;
+enum ELFDATA2MSB =     2;
+enum ELFDATANUM =      3;
+
+enum EI_VERSION =      6;
+
+enum EI_OSABI =        7;
+enum ELFOSABI_NONE =           0;
+enum ELFOSABI_SYSV =           0;
+enum ELFOSABI_HPUX =           1;
+enum ELFOSABI_NETBSD =         2;
+enum ELFOSABI_GNU =            3;
+enum ELFOSABI_LINUX =          ELFOSABI_GNU;
+enum ELFOSABI_HURD =           4;
+enum ELFOSABI_86OPEN =         5;
+enum ELFOSABI_SOLARIS =        6;
+enum ELFOSABI_AIX =            7;
+enum ELFOSABI_MONTEREY =       7;
+enum ELFOSABI_IRIX =           8;
+enum ELFOSABI_FREEBSD =        9;
+enum ELFOSABI_TRU64 =          10;
+enum ELFOSABI_MODESTO =        11;
+enum ELFOSABI_OPENBSD =        12;
+enum ELFOSABI_OPENVMS =        13;
+enum ELFOSABI_NSK =            14;
+enum ELFOSABI_AROS =           15;
+enum ELFOSABI_ARM_AEABI =      64;
+enum ELFOSABI_ARM =            97;
+enum ELFOSABI_STANDALONE =     255;
+enum ELFOSABI_DRAGONFLYBSD =   ELFOSABI_NONE;
+
+enum EI_ABIVERSION =   8;
+
+enum EI_PAD =          9;
+
+enum ET_NONE =         0;
+enum ET_REL =          1;
+enum ET_EXEC =         2;
+enum ET_DYN =          3;
+enum ET_CORE =         4;
+enum ET_NUM =          5;
+enum ET_LOOS =         0xfe00;
+enum ET_HIOS =         0xfeff;
+enum ET_LOPROC =       0xff00;
+enum ET_HIPROC =       0xffff;
+
+enum EM_NONE =          0;
+enum EM_M32 =           1;
+enum EM_SPARC =         2;
+enum EM_386 =           3;
+enum EM_68K =           4;
+enum EM_88K =           5;
+enum EM_860 =           7;
+enum EM_MIPS =          8;
+enum EM_S370 =          9;
+enum EM_MIPS_RS3_LE =  10;
+
+enum EM_PARISC =       15;
+enum EM_VPP500 =       17;
+enum EM_SPARC32PLUS =  18;
+enum EM_960 =          19;
+enum EM_PPC =          20;
+enum EM_PPC64 =        21;
+enum EM_S390 =         22;
+
+enum EM_V800 =         36;
+enum EM_FR20 =         37;
+enum EM_RH32 =         38;
+enum EM_RCE =          39;
+enum EM_ARM =          40;
+enum EM_FAKE_ALPHA =   41;
+enum EM_SH =           42;
+enum EM_SPARCV9 =      43;
+enum EM_TRICORE =      44;
+enum EM_ARC =          45;
+enum EM_H8_300 =       46;
+enum EM_H8_300H =      47;
+enum EM_H8S =          48;
+enum EM_H8_500 =       49;
+enum EM_IA_64 =        50;
+enum EM_MIPS_X =       51;
+enum EM_COLDFIRE =     52;
+enum EM_68HC12 =       53;
+enum EM_MMA =          54;
+enum EM_PCP =          55;
+enum EM_NCPU =         56;
+enum EM_NDR1 =         57;
+enum EM_STARCORE =     58;
+enum EM_ME16 =         59;
+enum EM_ST100 =        60;
+enum EM_TINYJ =        61;
+enum EM_X86_64 =       62;
+enum EM_PDSP =         63;
+
+enum EM_FX66 =         66;
+enum EM_ST9PLUS =      67;
+enum EM_ST7 =          68;
+enum EM_68HC16 =       69;
+enum EM_68HC11 =       70;
+enum EM_68HC08 =       71;
+enum EM_68HC05 =       72;
+enum EM_SVX =          73;
+enum EM_ST19 =         74;
+enum EM_VAX =          75;
+enum EM_CRIS =         76;
+enum EM_JAVELIN =      77;
+enum EM_FIREPATH =     78;
+enum EM_ZSP =          79;
+enum EM_MMIX =         80;
+enum EM_HUANY =        81;
+enum EM_PRISM =        82;
+enum EM_AVR =          83;
+enum EM_FR30 =         84;
+enum EM_D10V =         85;
+enum EM_D30V =         86;
+enum EM_V850 =         87;
+enum EM_M32R =         88;
+enum EM_MN10300 =      89;
+enum EM_MN10200 =      90;
+enum EM_PJ =           91;
+enum EM_OPENRISC =     92;
+enum EM_ARC_A5 =       93;
+enum EM_XTENSA =       94;
+enum EM_VIDEOCORE =    95;
+enum EM_TMM_GPP =      96;
+enum EM_NS32K =        97;
+enum EM_TPC =          98;
+enum EM_SNP1K =        99;
+enum EM_ST200 =       100;
+enum EM_IP2K =        101;
+enum EM_MAX =         102;
+enum EM_CR =          103;
+enum EM_F2MC16 =      104;
+enum EM_MSP430 =      105;
+enum EM_BLACKFIN =    106;
+enum EM_SE_C33 =      107;
+enum EM_SEP =         108;
+enum EM_ARCA =        109;
+enum EM_UNICORE =     110;
+enum EM_DXP =         112;
+enum EM_ALTERA_NIOS2 = 113;
+enum EM_CRX =         114;
+enum EM_XGATE =       115;
+enum EM_C166  =       116;
+enum EM_M16C  =       117;
+enum EM_DSPIC30F =    118;
+enum EM_CE =          119;
+enum EM_M32C  =       120;
+enum EM_res121 =      121;
+enum EM_res122 =      122;
+enum EM_res123 =      123;
+enum EM_res124 =      124;
+enum EM_res125 =      125;
+enum EM_res126 =      126;
+enum EM_res127 =      127;
+enum EM_res128 =      128;
+enum EM_res129 =      129;
+enum EM_res130 =      130;
+enum EM_TSK3000 =     131;
+enum EM_RS08  =       132;
+enum EM_res133 =      133;
+enum EM_ECOG2 =       134;
+enum EM_SCORE =       135;
+enum EM_SCORE7 =      135;
+enum EM_DSP24 =       136;
+enum EM_VIDEOCORE3 =  137;
+enum EM_LATTICEMICO32 = 138;
+enum EM_SE_C17 =      139;
+enum EM_TI_C6000 =    140;
+enum EM_TI_C2000 =    141;
+enum EM_TI_C5500 =    142;
+enum EM_TI_ARP32 =    143;
+enum EM_TI_PRU =      144;
+enum EM_MMDSP_PLUS =  160;
+enum EM_CYPRESS_M8C = 161;
+enum EM_R32C  =       162;
+enum EM_TRIMEDIA =    163;
+enum EM_QDSP6 =       164;
+enum EM_8051  =       165;
+enum EM_STXP7X =      166;
+enum EM_NDS32 =       167;
+enum EM_ECOG1 =       168;
+enum EM_ECOG1X =      168;
+enum EM_MAXQ30 =      169;
+enum EM_XIMO16 =      170;
+enum EM_MANIK =       171;
+enum EM_CRAYNV2 =     172;
+enum EM_RX =          173;
+enum EM_METAG =       174;
+enum EM_MCST_ELBRUS = 175;
+enum EM_ECOG16 =      176;
+enum EM_CR16  =       177;
+enum EM_ETPU  =       178;
+enum EM_SLE9X =       179;
+enum EM_L1OM  =       180;
+enum EM_K1OM  =       181;
+enum EM_INTEL182 =    182;
+enum EM_AARCH64 =     183;
+enum EM_AVR32 =       185;
+enum EM_STM8  =       186;
+enum EM_TILE64 =      187;
+enum EM_TILEPRO =     188;
+enum EM_MICROBLAZE =  189;
+enum EM_CUDA  =       190;
+enum EM_TILEGX =      191;
+enum EM_CLOUDSHIELD = 192;
+enum EM_COREA_1ST =   193;
+enum EM_COREA_2ND =   194;
+enum EM_ARCV2 =       195;
+enum EM_OPEN8 =       196;
+enum EM_RL78 =        197;
+enum EM_VIDEOCORE5 =  198;
+enum EM_78KOR =       199;
+enum EM_56800EX =     200;
+enum EM_BA1 =         201;
+enum EM_BA2 =         202;
+enum EM_XCORE =       203;
+enum EM_MCHP_PIC =    204;
+enum EM_INTELGT =     205;
+
+enum EM_KM32 =        210;
+enum EM_KMX32 =       211;
+enum EM_EMX16 =       212;
+enum EM_EMX8 =        213;
+enum EM_KVARC =       214;
+enum EM_CDP =         215;
+enum EM_COGE =        216;
+enum EM_COOL =        217;
+enum EM_NORC =        218;
+enum EM_CSR_KALIMBA = 219;
+enum EM_Z80 =         220;
+enum EM_VISIUM =      221;
+enum EM_FT32 =        222;
+enum EM_MOXIE =       223;
+enum EM_AMDGPU =      224;
+
+enum EM_RISCV =       243;
+
+enum EM_BPF =         247;
+enum EM_CSKY =        252;
+
+enum EM_NUM =         253;
+
+enum EM_ALPHA =        0x9026;
+
+enum EV_NONE =         0;
+enum EV_CURRENT =      1;
+enum EV_NUM =          2;
+
+struct Elf32_Shdr
+{
+  Elf32_Word    sh_name;
+  Elf32_Word    sh_type;
+  Elf32_Word    sh_flags;
+  Elf32_Addr    sh_addr;
+  Elf32_Off     sh_offset;
+  Elf32_Word    sh_size;
+  Elf32_Word    sh_link;
+  Elf32_Word    sh_info;
+  Elf32_Word    sh_addralign;
+  Elf32_Word    sh_entsize;
+}
+
+struct Elf64_Shdr
+{
+  Elf64_Word    sh_name;
+  Elf64_Word    sh_type;
+  Elf64_Xword   sh_flags;
+  Elf64_Addr    sh_addr;
+  Elf64_Off     sh_offset;
+  Elf64_Xword   sh_size;
+  Elf64_Word    sh_link;
+  Elf64_Word    sh_info;
+  Elf64_Xword   sh_addralign;
+  Elf64_Xword   sh_entsize;
+}
+
+enum SHN_UNDEF =       0;
+enum SHN_LORESERVE =   0xff00;
+enum SHN_LOPROC =      0xff00;
+enum SHN_BEFORE =      0xff00;
+enum SHN_AFTER =       0xff01;
+enum SHN_HIPROC =      0xff1f;
+enum SHN_LOOS =        0xff20;
+enum SHN_HIOS =        0xff3f;
+enum SHN_ABS =         0xfff1;
+enum SHN_COMMON =      0xfff2;
+enum SHN_XINDEX =      0xffff;
+enum SHN_HIRESERVE =   0xffff;
+
+enum SHT_NULL =          0;
+enum SHT_PROGBITS =      1;
+enum SHT_SYMTAB =        2;
+enum SHT_STRTAB =        3;
+enum SHT_RELA =          4;
+enum SHT_HASH =          5;
+enum SHT_DYNAMIC =       6;
+enum SHT_NOTE =          7;
+enum SHT_NOBITS =        8;
+enum SHT_REL =           9;
+enum SHT_SHLIB =         10;
+enum SHT_DYNSYM =        11;
+enum SHT_INIT_ARRAY =    14;
+enum SHT_FINI_ARRAY =    15;
+enum SHT_PREINIT_ARRAY = 16;
+enum SHT_GROUP =         17;
+enum SHT_SYMTAB_SHNDX =  18;
+enum SHT_NUM =           19;
+enum SHT_LOOS =          0x60000000;
+enum SHT_GNU_ATTRIBUTES = 0x6ffffff5;
+enum SHT_GNU_HASH =      0x6ffffff6;
+enum SHT_GNU_LIBLIST =   0x6ffffff7;
+enum SHT_CHECKSUM =      0x6ffffff8;
+enum SHT_LOSUNW =        0x6ffffffa;
+enum SHT_SUNW_move =     0x6ffffffa;
+enum SHT_SUNW_COMDAT =   0x6ffffffb;
+enum SHT_SUNW_syminfo =  0x6ffffffc;
+enum SHT_GNU_verdef =    0x6ffffffd;
+enum SHT_GNU_verneed =   0x6ffffffe;
+enum SHT_GNU_versym =    0x6fffffff;
+enum SHT_HISUNW =        0x6fffffff;
+enum SHT_HIOS =          0x6fffffff;
+enum SHT_LOPROC =        0x70000000;
+enum SHT_HIPROC =        0x7fffffff;
+enum SHT_LOUSER =        0x80000000;
+enum SHT_HIUSER =        0x8fffffff;
+
+enum SHF_WRITE =            (1 << 0);
+enum SHF_ALLOC =            (1 << 1);
+enum SHF_EXECINSTR =        (1 << 2);
+enum SHF_MERGE =            (1 << 4);
+enum SHF_STRINGS =          (1 << 5);
+enum SHF_INFO_LINK =        (1 << 6);
+enum SHF_LINK_ORDER =       (1 << 7);
+enum SHF_OS_NONCONFORMING = (1 << 8);
+enum SHF_GROUP =            (1 << 9);
+enum SHF_TLS =              (1 << 10);
+enum SHF_COMPRESSED =       (1 << 11);
+enum SHF_MASKOS =           0x0ff00000;
+enum SHF_MASKPROC =         0xf0000000;
+enum SHF_ORDERED =          (1 << 30);
+enum SHF_EXCLUDE =          (1 << 31);
+enum GRP_COMDAT =      0x1;
+
+struct Elf32_Sym
+{
+  Elf32_Word    st_name;
+  Elf32_Addr    st_value;
+  Elf32_Word    st_size;
+  ubyte st_info;
+  ubyte st_other;
+  Elf32_Section st_shndx;
+}
+
+struct Elf64_Sym
+{
+  Elf64_Word    st_name;
+  ubyte st_info;
+  ubyte st_other;
+  Elf64_Section st_shndx;
+  Elf64_Addr    st_value;
+  Elf64_Xword   st_size;
+}
+
+struct Elf32_Syminfo
+{
+  Elf32_Half si_boundto;
+  Elf32_Half si_flags;
+}
+
+struct Elf64_Syminfo
+{
+  Elf64_Half si_boundto;
+  Elf64_Half si_flags;
+}
+
+enum SYMINFO_BT_SELF =         0xffff;
+enum SYMINFO_BT_PARENT =       0xfffe;
+enum SYMINFO_BT_LOWRESERVE =   0xff00;
+
+enum SYMINFO_FLG_DIRECT =      0x0001;
+enum SYMINFO_FLG_PASSTHRU =    0x0002;
+enum SYMINFO_FLG_COPY =        0x0004;
+enum SYMINFO_FLG_LAZYLOAD =    0x0008;
+
+enum SYMINFO_NONE =            0;
+enum SYMINFO_CURRENT =         1;
+enum SYMINFO_NUM =             2;
+
+extern (D)
+{
+    auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
+    auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; }
+    auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); }
+    alias ELF32_ST_BIND ELF64_ST_BIND;
+    alias ELF32_ST_TYPE ELF64_ST_TYPE;
+    alias ELF32_ST_INFO ELF64_ST_INFO;
+}
+
+enum STB_LOCAL =       0;
+enum STB_GLOBAL =      1;
+enum STB_WEAK =        2;
+enum STB_NUM =         3;
+enum STB_LOOS =        10;
+enum STB_GNU_UNIQUE =  10;
+enum STB_HIOS =        12;
+enum STB_LOPROC =      13;
+enum STB_HIPROC =      15;
+
+enum STT_NOTYPE =      0;
+enum STT_OBJECT =      1;
+enum STT_FUNC =        2;
+enum STT_SECTION =     3;
+enum STT_FILE =        4;
+enum STT_COMMON =      5;
+enum STT_TLS =         6;
+enum STT_NUM =         7;
+enum STT_LOOS =        10;
+enum STT_GNU_IFUNC =   10;
+enum STT_HIOS =        12;
+enum STT_LOPROC =      13;
+enum STT_HIPROC =      15;
+
+enum STN_UNDEF =       0;
+
+enum STV_DEFAULT =     0;
+enum STV_INTERNAL =    1;
+enum STV_HIDDEN =      2;
+enum STV_PROTECTED =   3;
+
+struct Elf32_Rel
+{
+  Elf32_Addr    r_offset;
+  Elf32_Word    r_info;
+}
+
+struct Elf64_Rel
+{
+  Elf64_Addr    r_offset;
+  Elf64_Xword   r_info;
+}
+
+struct Elf32_Rela
+{
+  Elf32_Addr    r_offset;
+  Elf32_Word    r_info;
+  Elf32_Sword   r_addend;
+}
+
+struct Elf64_Rela
+{
+  Elf64_Addr    r_offset;
+  Elf64_Xword   r_info;
+  Elf64_Sxword  r_addend;
+}
+
+extern (D)
+{
+    auto ELF32_R_SYM(V)(V val) { return val >> 8; }
+    auto ELF32_R_TYPE(V)(V val) { return val & 0xff; }
+    auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); }
+
+    auto ELF64_R_SYM(I)(I i) { return i >> 32; }
+    auto ELF64_R_TYPE(I)(I i) { return i & 0xffffffff; }
+    auto ELF64_R_INFO(S, T)(S sym, T type) { return (sym << 32) + (type); }
+}
+
+struct Elf32_Phdr
+{
+  Elf32_Word    p_type;
+  Elf32_Off     p_offset;
+  Elf32_Addr    p_vaddr;
+  Elf32_Addr    p_paddr;
+  Elf32_Word    p_filesz;
+  Elf32_Word    p_memsz;
+  Elf32_Word    p_flags;
+  Elf32_Word    p_align;
+}
+
+struct Elf64_Phdr
+{
+  Elf64_Word    p_type;
+  Elf64_Word    p_flags;
+  Elf64_Off     p_offset;
+  Elf64_Addr    p_vaddr;
+  Elf64_Addr    p_paddr;
+  Elf64_Xword   p_filesz;
+  Elf64_Xword   p_memsz;
+  Elf64_Xword   p_align;
+}
+
+enum PN_XNUM =         0xffff;
+
+enum PT_NULL =         0;
+enum PT_LOAD =         1;
+enum PT_DYNAMIC =      2;
+enum PT_INTERP =       3;
+enum PT_NOTE =         4;
+enum PT_SHLIB =        5;
+enum PT_PHDR =         6;
+enum PT_TLS =          7;
+enum PT_NUM =          8;
+enum PT_LOOS =         0x60000000;
+enum PT_GNU_EH_FRAME = 0x6474e550;
+enum PT_GNU_STACK =    0x6474e551;
+enum PT_GNU_RELRO =    0x6474e552;
+enum PT_LOSUNW =       0x6ffffffa;
+enum PT_SUNWBSS =      0x6ffffffa;
+enum PT_SUNWSTACK =    0x6ffffffb;
+enum PT_HISUNW =       0x6fffffff;
+enum PT_HIOS =         0x6fffffff;
+enum PT_LOPROC =       0x70000000;
+enum PT_HIPROC =       0x7fffffff;
+
+enum PF_X =            (1 << 0);
+enum PF_W =            (1 << 1);
+enum PF_R =            (1 << 2);
+enum PF_MASKOS =       0x0ff00000;
+enum PF_MASKPROC =     0xf0000000;
+
+struct Elf32_Dyn
+{
+  Elf32_Sword   d_tag;
+  union _d_un
+  {
+      Elf32_Word d_val;
+      Elf32_Addr d_ptr;
+  } _d_un d_un;
+}
+
+struct Elf64_Dyn
+{
+  Elf64_Sxword  d_tag;
+  union _d_un
+  {
+      Elf64_Xword d_val;
+      Elf64_Addr d_ptr;
+  } _d_un d_un;
+}
+
+enum DT_NULL =         0;
+enum DT_NEEDED =       1;
+enum DT_PLTRELSZ =     2;
+enum DT_PLTGOT =       3;
+enum DT_HASH =         4;
+enum DT_STRTAB =       5;
+enum DT_SYMTAB =       6;
+enum DT_RELA =         7;
+enum DT_RELASZ =       8;
+enum DT_RELAENT =      9;
+enum DT_STRSZ =        10;
+enum DT_SYMENT =       11;
+enum DT_INIT =         12;
+enum DT_FINI =         13;
+enum DT_SONAME =       14;
+enum DT_RPATH =        15;
+enum DT_SYMBOLIC =     16;
+enum DT_REL =          17;
+enum DT_RELSZ =        18;
+enum DT_RELENT =       19;
+enum DT_PLTREL =       20;
+enum DT_DEBUG =        21;
+enum DT_TEXTREL =      22;
+enum DT_JMPREL =       23;
+enum DT_BIND_NOW =     24;
+enum DT_INIT_ARRAY =   25;
+enum DT_FINI_ARRAY =   26;
+enum DT_INIT_ARRAYSZ = 27;
+enum DT_FINI_ARRAYSZ = 28;
+enum DT_RUNPATH =      29;
+enum DT_FLAGS =        30;
+enum DT_ENCODING =     32;
+enum DT_PREINIT_ARRAY = 32;
+enum DT_PREINIT_ARRAYSZ = 33;
+enum DT_NUM =          34;
+enum DT_LOOS =         0x6000000d;
+enum DT_HIOS =         0x6ffff000;
+enum DT_LOPROC =       0x70000000;
+enum DT_HIPROC =       0x7fffffff;
+enum DT_PROCNUM =      DT_MIPS_NUM;
+enum DT_VALRNGLO =     0x6ffffd00;
+enum DT_GNU_PRELINKED = 0x6ffffdf5;
+enum DT_GNU_CONFLICTSZ = 0x6ffffdf6;
+enum DT_GNU_LIBLISTSZ = 0x6ffffdf7;
+enum DT_CHECKSUM =     0x6ffffdf8;
+enum DT_PLTPADSZ =     0x6ffffdf9;
+enum DT_MOVEENT =      0x6ffffdfa;
+enum DT_MOVESZ =       0x6ffffdfb;
+enum DT_FEATURE_1 =    0x6ffffdfc;
+enum DT_POSFLAG_1 =    0x6ffffdfd;
+enum DT_SYMINSZ =      0x6ffffdfe;
+enum DT_SYMINENT =     0x6ffffdff;
+enum DT_VALRNGHI =     0x6ffffdff;
+extern (D) auto DT_VALTAGIDX(T)(T tag)
+{
+    return DT_VALRNGHI - tag;
+}
+enum DT_VALNUM = 12;
+enum DT_ADDRRNGLO =    0x6ffffe00;
+enum DT_GNU_HASH =     0x6ffffef5;
+enum DT_TLSDESC_PLT =  0x6ffffef6;
+enum DT_TLSDESC_GOT =  0x6ffffef7;
+enum DT_GNU_CONFLICT = 0x6ffffef8;
+enum DT_GNU_LIBLIST =  0x6ffffef9;
+enum DT_CONFIG =       0x6ffffefa;
+enum DT_DEPAUDIT =     0x6ffffefb;
+enum DT_AUDIT =        0x6ffffefc;
+enum DT_PLTPAD =       0x6ffffefd;
+enum DT_MOVETAB =      0x6ffffefe;
+enum DT_SYMINFO =      0x6ffffeff;
+enum DT_ADDRRNGHI =    0x6ffffeff;
+extern (D) auto DT_ADDRTAGIDX(T)(T tag)
+{
+    return DT_ADDRRNGHI - tag;
+}
+enum DT_ADDRNUM = 11;
+enum DT_VERSYM =       0x6ffffff0;
+
+enum DT_RELACOUNT =    0x6ffffff9;
+enum DT_RELCOUNT =     0x6ffffffa;
+enum DT_FLAGS_1 =      0x6ffffffb;
+enum DT_VERDEF =       0x6ffffffc;
+enum DT_VERDEFNUM =    0x6ffffffd;
+enum DT_VERNEED =      0x6ffffffe;
+enum DT_VERNEEDNUM =   0x6fffffff;
+extern (D) auto DT_VERSIONTAGIDX(T)(T tag)
+{
+    return DT_VERNEEDNUM - tag;
+}
+enum DT_VERSIONTAGNUM = 16;
+enum DT_AUXILIARY =    0x7ffffffd;
+enum DT_FILTER =       0x7fffffff;
+extern (D) auto DT_EXTRATAGIDX(T)(T tag)
+{
+    return cast(Elf32_Word)(-(cast(Elf32_Sword)(tag) <<1>>1)-1);
+}
+enum DT_EXTRANUM =     3;
+enum DF_ORIGIN =       0x00000001;
+enum DF_SYMBOLIC =     0x00000002;
+enum DF_TEXTREL =      0x00000004;
+enum DF_BIND_NOW =     0x00000008;
+enum DF_STATIC_TLS =   0x00000010;
+enum DF_1_NOW =        0x00000001;
+enum DF_1_GLOBAL =     0x00000002;
+enum DF_1_GROUP =      0x00000004;
+enum DF_1_NODELETE =   0x00000008;
+enum DF_1_LOADFLTR =   0x00000010;
+enum DF_1_INITFIRST =  0x00000020;
+enum DF_1_NOOPEN =     0x00000040;
+enum DF_1_ORIGIN =     0x00000080;
+enum DF_1_DIRECT =     0x00000100;
+enum DF_1_TRANS =      0x00000200;
+enum DF_1_INTERPOSE =  0x00000400;
+enum DF_1_NODEFLIB =   0x00000800;
+enum DF_1_NODUMP =     0x00001000;
+enum DF_1_CONFALT =    0x00002000;
+enum DF_1_ENDFILTEE =  0x00004000;
+enum DF_1_DISPRELDNE = 0x00008000;
+enum DF_1_DISPRELPND = 0x00010000;
+enum DF_1_NODIRECT =   0x00020000;
+enum DF_1_IGNMULDEF =  0x00040000;
+enum DF_1_NOKSYMS =    0x00080000;
+enum DF_1_NOHDR =      0x00100000;
+enum DF_1_EDITED =     0x00200000;
+enum DF_1_NORELOC =    0x00400000;
+enum DF_1_SYMINTPOSE = 0x00800000;
+enum DF_1_GLOBAUDIT =  0x01000000;
+enum DF_1_SINGLETON =  0x02000000;
+enum DTF_1_PARINIT =   0x00000001;
+enum DTF_1_CONFEXP =   0x00000002;
+enum DF_P1_LAZYLOAD =  0x00000001;
+enum DF_P1_GROUPPERM = 0x00000002;
+
+struct Elf32_Verdef
+{
+    Elf32_Half    vd_version;
+    Elf32_Half    vd_flags;
+    Elf32_Half    vd_ndx;
+    Elf32_Half    vd_cnt;
+    Elf32_Word    vd_hash;
+    Elf32_Word    vd_aux;
+    Elf32_Word    vd_next;
+}
+
+struct Elf64_Verdef
+{
+    Elf64_Half    vd_version;
+    Elf64_Half    vd_flags;
+    Elf64_Half    vd_ndx;
+    Elf64_Half    vd_cnt;
+    Elf64_Word    vd_hash;
+    Elf64_Word    vd_aux;
+    Elf64_Word    vd_next;
+}
+enum VER_DEF_NONE =    0;
+enum VER_DEF_CURRENT = 1;
+enum VER_DEF_NUM =     2;
+enum VER_FLG_BASE =    0x1;
+enum VER_FLG_WEAK =    0x2;
+enum VER_NDX_LOCAL =           0;
+enum VER_NDX_GLOBAL =          1;
+enum VER_NDX_LORESERVE =       0xff00;
+enum VER_NDX_ELIMINATE =       0xff01;
+
+struct Elf32_Verdaux
+{
+    Elf32_Word    vda_name;
+    Elf32_Word    vda_next;
+}
+
+struct Elf64_Verdaux
+{
+    Elf64_Word    vda_name;
+    Elf64_Word    vda_next;
+}
+
+struct Elf32_Verneed
+{
+    Elf32_Half    vn_version;
+    Elf32_Half    vn_cnt;
+    Elf32_Word    vn_file;
+    Elf32_Word    vn_aux;
+    Elf32_Word    vn_next;
+}
+
+struct Elf64_Verneed
+{
+    Elf64_Half    vn_version;
+    Elf64_Half    vn_cnt;
+    Elf64_Word    vn_file;
+    Elf64_Word    vn_aux;
+    Elf64_Word    vn_next;
+}
+enum VER_NEED_NONE =    0;
+enum VER_NEED_CURRENT = 1;
+enum VER_NEED_NUM =     2;
+
+struct Elf32_Vernaux
+{
+    Elf32_Word    vna_hash;
+    Elf32_Half    vna_flags;
+    Elf32_Half    vna_other;
+    Elf32_Word    vna_name;
+    Elf32_Word    vna_next;
+}
+
+struct Elf64_Vernaux
+{
+    Elf64_Word    vna_hash;
+    Elf64_Half    vna_flags;
+    Elf64_Half    vna_other;
+    Elf64_Word    vna_name;
+    Elf64_Word    vna_next;
+}
+
+enum ELF_NOTE_SOLARIS =        "SUNW Solaris";
+enum ELF_NOTE_GNU =            "GNU";
+enum ELF_NOTE_PAGESIZE_HINT =  1;
+enum ELF_NOTE_ABI =    1;
+enum ELF_NOTE_OS_LINUX =       0;
+enum ELF_NOTE_OS_GNU =         1;
+enum ELF_NOTE_OS_SOLARIS2 =    2;
+enum ELF_NOTE_OS_FREEBSD =     3;
+
+struct Elf32_Move
+{
+  Elf32_Xword m_value;
+  Elf32_Word m_info;
+  Elf32_Word m_poffset;
+  Elf32_Half m_repeat;
+  Elf32_Half m_stride;
+}
+
+struct Elf64_Move
+{
+  Elf64_Xword m_value;
+  Elf64_Xword m_info;
+  Elf64_Xword m_poffset;
+  Elf64_Half m_repeat;
+  Elf64_Half m_stride;
+}
+extern (D)
+{
+    auto ELF32_M_SYM(I)(I info) { return info >> 8; }
+    auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; }
+    auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; }
+}
+
+alias ELF32_M_SYM ELF64_M_SYM;
+alias ELF32_M_SIZE ELF64_M_SIZE;
+alias ELF32_M_INFO ELF64_M_INFO;
+enum EF_CPU32 =        0x00810000;
+
+enum R_68K_NONE =      0;
+enum R_68K_32 =        1;
+enum R_68K_16 =        2;
+enum R_68K_8 =         3;
+enum R_68K_PC32 =      4;
+enum R_68K_PC16 =      5;
+enum R_68K_PC8 =       6;
+enum R_68K_GOT32 =     7;
+enum R_68K_GOT16 =     8;
+enum R_68K_GOT8 =      9;
+enum R_68K_GOT32O =    10;
+enum R_68K_GOT16O =    11;
+enum R_68K_GOT8O =     12;
+enum R_68K_PLT32 =     13;
+enum R_68K_PLT16 =     14;
+enum R_68K_PLT8 =      15;
+enum R_68K_PLT32O =    16;
+enum R_68K_PLT16O =    17;
+enum R_68K_PLT8O =     18;
+enum R_68K_COPY =      19;
+enum R_68K_GLOB_DAT =  20;
+enum R_68K_JMP_SLOT =  21;
+enum R_68K_RELATIVE =  22;
+enum R_68K_TLS_GD32 =      25;
+enum R_68K_TLS_GD16 =      26;
+enum R_68K_TLS_GD8 =       27;
+enum R_68K_TLS_LDM32 =     28;
+enum R_68K_TLS_LDM16 =     29;
+enum R_68K_TLS_LDM8 =      30;
+enum R_68K_TLS_LDO32 =     31;
+enum R_68K_TLS_LDO16 =     32;
+enum R_68K_TLS_LDO8 =      33;
+enum R_68K_TLS_IE32 =      34;
+enum R_68K_TLS_IE16 =      35;
+enum R_68K_TLS_IE8 =       36;
+enum R_68K_TLS_LE32 =      37;
+enum R_68K_TLS_LE16 =      38;
+enum R_68K_TLS_LE8 =       39;
+enum R_68K_TLS_DTPMOD32 =  40;
+enum R_68K_TLS_DTPREL32 =  41;
+enum R_68K_TLS_TPREL32 =   42;
+enum R_68K_NUM =       43;
+
+enum R_386_NONE =         0;
+enum R_386_32 =           1;
+enum R_386_PC32 =         2;
+enum R_386_GOT32 =        3;
+enum R_386_PLT32 =        4;
+enum R_386_COPY =         5;
+enum R_386_GLOB_DAT =     6;
+enum R_386_JMP_SLOT =     7;
+enum R_386_RELATIVE =     8;
+enum R_386_GOTOFF =       9;
+enum R_386_GOTPC =        10;
+enum R_386_32PLT =        11;
+enum R_386_TLS_TPOFF =    14;
+enum R_386_TLS_IE =       15;
+enum R_386_TLS_GOTIE =    16;
+enum R_386_TLS_LE =       17;
+enum R_386_TLS_GD =       18;
+enum R_386_TLS_LDM =      19;
+enum R_386_16 =           20;
+enum R_386_PC16 =         21;
+enum R_386_8 =            22;
+enum R_386_PC8 =          23;
+enum R_386_TLS_GD_32 =    24;
+enum R_386_TLS_GD_PUSH =  25;
+enum R_386_TLS_GD_CALL =  26;
+enum R_386_TLS_GD_POP =   27;
+enum R_386_TLS_LDM_32 =   28;
+enum R_386_TLS_LDM_PUSH = 29;
+enum R_386_TLS_LDM_CALL = 30;
+enum R_386_TLS_LDM_POP =  31;
+enum R_386_TLS_LDO_32 =   32;
+enum R_386_TLS_IE_32 =    33;
+enum R_386_TLS_LE_32 =    34;
+enum R_386_TLS_DTPMOD32 = 35;
+enum R_386_TLS_DTPOFF32 = 36;
+enum R_386_TLS_TPOFF32 =  37;
+enum R_386_SIZE32 =       38;
+enum R_386_TLS_GOTDESC =  39;
+enum R_386_TLS_DESC_CALL = 40;
+enum R_386_TLS_DESC =     41;
+enum R_386_IRELATIVE =    42;
+enum R_386_NUM =          43;
+
+enum STT_SPARC_REGISTER =      13;
+
+enum EF_SPARCV9_MM =           3;
+enum EF_SPARCV9_TSO =          0;
+enum EF_SPARCV9_PSO =          1;
+enum EF_SPARCV9_RMO =          2;
+enum EF_SPARC_LEDATA =         0x800000;
+enum EF_SPARC_EXT_MASK =       0xFFFF00;
+enum EF_SPARC_32PLUS =         0x000100;
+enum EF_SPARC_SUN_US1 =        0x000200;
+enum EF_SPARC_HAL_R1 =         0x000400;
+enum EF_SPARC_SUN_US3 =        0x000800;
+
+enum R_SPARC_NONE =            0;
+enum R_SPARC_8 =               1;
+enum R_SPARC_16 =              2;
+enum R_SPARC_32 =              3;
+enum R_SPARC_DISP8 =           4;
+enum R_SPARC_DISP16 =          5;
+enum R_SPARC_DISP32 =          6;
+enum R_SPARC_WDISP30 =         7;
+enum R_SPARC_WDISP22 =         8;
+enum R_SPARC_HI22 =            9;
+enum R_SPARC_22 =              10;
+enum R_SPARC_13 =              11;
+enum R_SPARC_LO10 =            12;
+enum R_SPARC_GOT10 =           13;
+enum R_SPARC_GOT13 =           14;
+enum R_SPARC_GOT22 =           15;
+enum R_SPARC_PC10 =            16;
+enum R_SPARC_PC22 =            17;
+enum R_SPARC_WPLT30 =          18;
+enum R_SPARC_COPY =            19;
+enum R_SPARC_GLOB_DAT =        20;
+enum R_SPARC_JMP_SLOT =        21;
+enum R_SPARC_RELATIVE =        22;
+enum R_SPARC_UA32 =            23;
+
+enum R_SPARC_PLT32 =           24;
+enum R_SPARC_HIPLT22 =         25;
+enum R_SPARC_LOPLT10 =         26;
+enum R_SPARC_PCPLT32 =         27;
+enum R_SPARC_PCPLT22 =         28;
+enum R_SPARC_PCPLT10 =         29;
+enum R_SPARC_10 =              30;
+enum R_SPARC_11 =              31;
+enum R_SPARC_64 =              32;
+enum R_SPARC_OLO10 =           33;
+enum R_SPARC_HH22 =            34;
+enum R_SPARC_HM10 =            35;
+enum R_SPARC_LM22 =            36;
+enum R_SPARC_PC_HH22 =         37;
+enum R_SPARC_PC_HM10 =         38;
+enum R_SPARC_PC_LM22 =         39;
+enum R_SPARC_WDISP16 =         40;
+enum R_SPARC_WDISP19 =         41;
+enum R_SPARC_GLOB_JMP =        42;
+enum R_SPARC_7 =               43;
+enum R_SPARC_5 =               44;
+enum R_SPARC_6 =               45;
+enum R_SPARC_DISP64 =          46;
+enum R_SPARC_PLT64 =           47;
+enum R_SPARC_HIX22 =           48;
+enum R_SPARC_LOX10 =           49;
+enum R_SPARC_H44 =             50;
+enum R_SPARC_M44 =             51;
+enum R_SPARC_L44 =             52;
+enum R_SPARC_REGISTER =        53;
+enum R_SPARC_UA64 =            54;
+enum R_SPARC_UA16 =            55;
+enum R_SPARC_TLS_GD_HI22 =     56;
+enum R_SPARC_TLS_GD_LO10 =     57;
+enum R_SPARC_TLS_GD_ADD =      58;
+enum R_SPARC_TLS_GD_CALL =     59;
+enum R_SPARC_TLS_LDM_HI22 =    60;
+enum R_SPARC_TLS_LDM_LO10 =    61;
+enum R_SPARC_TLS_LDM_ADD =     62;
+enum R_SPARC_TLS_LDM_CALL =    63;
+enum R_SPARC_TLS_LDO_HIX22 =   64;
+enum R_SPARC_TLS_LDO_LOX10 =   65;
+enum R_SPARC_TLS_LDO_ADD =     66;
+enum R_SPARC_TLS_IE_HI22 =     67;
+enum R_SPARC_TLS_IE_LO10 =     68;
+enum R_SPARC_TLS_IE_LD =       69;
+enum R_SPARC_TLS_IE_LDX =      70;
+enum R_SPARC_TLS_IE_ADD =      71;
+enum R_SPARC_TLS_LE_HIX22 =    72;
+enum R_SPARC_TLS_LE_LOX10 =    73;
+enum R_SPARC_TLS_DTPMOD32 =    74;
+enum R_SPARC_TLS_DTPMOD64 =    75;
+enum R_SPARC_TLS_DTPOFF32 =    76;
+enum R_SPARC_TLS_DTPOFF64 =    77;
+enum R_SPARC_TLS_TPOFF32 =     78;
+enum R_SPARC_TLS_TPOFF64 =     79;
+enum R_SPARC_GOTDATA_HIX22 =   80;
+enum R_SPARC_GOTDATA_LOX10 =   81;
+enum R_SPARC_GOTDATA_OP_HIX22 =        82;
+enum R_SPARC_GOTDATA_OP_LOX10 =        83;
+enum R_SPARC_GOTDATA_OP =      84;
+enum R_SPARC_H34 =             85;
+enum R_SPARC_SIZE32 =          86;
+enum R_SPARC_SIZE64 =          87;
+enum R_SPARC_WDISP10 =         88;
+enum R_SPARC_JMP_IREL =        248;
+enum R_SPARC_IRELATIVE =       249;
+enum R_SPARC_GNU_VTINHERIT =   250;
+enum R_SPARC_GNU_VTENTRY =     251;
+enum R_SPARC_REV32 =           252;
+enum R_SPARC_NUM =             253;
+
+enum DT_SPARC_REGISTER =       0x70000001;
+enum DT_SPARC_NUM =            2;
+
+enum EF_MIPS_NOREORDER =       1;
+enum EF_MIPS_PIC =             2;
+enum EF_MIPS_CPIC =            4;
+enum EF_MIPS_XGOT =            8;
+enum EF_MIPS_64BIT_WHIRL =     16;
+enum EF_MIPS_ABI2 =            32;
+enum EF_MIPS_ABI_ON32 =        64;
+enum EF_MIPS_ARCH =            0xf0000000;
+
+enum EF_MIPS_ARCH_1 =          0x00000000;
+enum EF_MIPS_ARCH_2 =          0x10000000;
+enum EF_MIPS_ARCH_3 =          0x20000000;
+enum EF_MIPS_ARCH_4 =          0x30000000;
+enum EF_MIPS_ARCH_5 =          0x40000000;
+enum EF_MIPS_ARCH_32 =         0x50000000;
+enum EF_MIPS_ARCH_64 =         0x60000000;
+enum EF_MIPS_ARCH_32R2 =       0x70000000;
+enum EF_MIPS_ARCH_64R2 =       0x80000000;
+
+enum E_MIPS_ARCH_1 =           EF_MIPS_ARCH_1;
+enum E_MIPS_ARCH_2 =           EF_MIPS_ARCH_2;
+enum E_MIPS_ARCH_3 =           EF_MIPS_ARCH_3;
+enum E_MIPS_ARCH_4 =           EF_MIPS_ARCH_4;
+enum E_MIPS_ARCH_5 =           EF_MIPS_ARCH_5;
+enum E_MIPS_ARCH_32 =          EF_MIPS_ARCH_32;
+enum E_MIPS_ARCH_64 =          EF_MIPS_ARCH_64;
+
+enum SHN_MIPS_ACOMMON =        0xff00;
+enum SHN_MIPS_TEXT =           0xff01;
+enum SHN_MIPS_DATA =           0xff02;
+enum SHN_MIPS_SCOMMON =        0xff03;
+enum SHN_MIPS_SUNDEFINED =     0xff04;
+
+enum SHT_MIPS_LIBLIST =        0x70000000;
+enum SHT_MIPS_MSYM =           0x70000001;
+enum SHT_MIPS_CONFLICT =       0x70000002;
+enum SHT_MIPS_GPTAB =          0x70000003;
+enum SHT_MIPS_UCODE =          0x70000004;
+enum SHT_MIPS_DEBUG =          0x70000005;
+enum SHT_MIPS_REGINFO =        0x70000006;
+enum SHT_MIPS_PACKAGE =        0x70000007;
+enum SHT_MIPS_PACKSYM =        0x70000008;
+enum SHT_MIPS_RELD =           0x70000009;
+enum SHT_MIPS_IFACE =          0x7000000b;
+enum SHT_MIPS_CONTENT =        0x7000000c;
+enum SHT_MIPS_OPTIONS =        0x7000000d;
+enum SHT_MIPS_SHDR =           0x70000010;
+enum SHT_MIPS_FDESC =          0x70000011;
+enum SHT_MIPS_EXTSYM =         0x70000012;
+enum SHT_MIPS_DENSE =          0x70000013;
+enum SHT_MIPS_PDESC =          0x70000014;
+enum SHT_MIPS_LOCSYM =         0x70000015;
+enum SHT_MIPS_AUXSYM =         0x70000016;
+enum SHT_MIPS_OPTSYM =         0x70000017;
+enum SHT_MIPS_LOCSTR =         0x70000018;
+enum SHT_MIPS_LINE =           0x70000019;
+enum SHT_MIPS_RFDESC =         0x7000001a;
+enum SHT_MIPS_DELTASYM =       0x7000001b;
+enum SHT_MIPS_DELTAINST =      0x7000001c;
+enum SHT_MIPS_DELTACLASS =     0x7000001d;
+enum SHT_MIPS_DWARF =          0x7000001e;
+enum SHT_MIPS_DELTADECL =      0x7000001f;
+enum SHT_MIPS_SYMBOL_LIB =     0x70000020;
+enum SHT_MIPS_EVENTS =         0x70000021;
+enum SHT_MIPS_TRANSLATE =      0x70000022;
+enum SHT_MIPS_PIXIE =          0x70000023;
+enum SHT_MIPS_XLATE =          0x70000024;
+enum SHT_MIPS_XLATE_DEBUG =    0x70000025;
+enum SHT_MIPS_WHIRL =          0x70000026;
+enum SHT_MIPS_EH_REGION =      0x70000027;
+enum SHT_MIPS_XLATE_OLD =      0x70000028;
+enum SHT_MIPS_PDR_EXCEPTION =  0x70000029;
+
+enum SHF_MIPS_GPREL =          0x10000000;
+enum SHF_MIPS_MERGE =          0x20000000;
+enum SHF_MIPS_ADDR =           0x40000000;
+enum SHF_MIPS_STRINGS =        0x80000000;
+enum SHF_MIPS_NOSTRIP =        0x08000000;
+enum SHF_MIPS_LOCAL =          0x04000000;
+enum SHF_MIPS_NAMES =          0x02000000;
+enum SHF_MIPS_NODUPE =         0x01000000;
+enum STO_MIPS_DEFAULT =                0x0;
+enum STO_MIPS_INTERNAL =               0x1;
+enum STO_MIPS_HIDDEN =                 0x2;
+enum STO_MIPS_PROTECTED =              0x3;
+enum STO_MIPS_PLT =                    0x8;
+enum STO_MIPS_SC_ALIGN_UNUSED =        0xff;
+enum STB_MIPS_SPLIT_COMMON =           13;
+
+union Elf32_gptab
+{
+    struct _gt_header
+    {
+        Elf32_Word gt_current_g_value;
+        Elf32_Word gt_unused;
+    } _gt_header gt_header;
+    struct _gt_entry
+    {
+        Elf32_Word gt_g_value;
+        Elf32_Word gt_bytes;
+    } _gt_entry gt_entry;
+}
+
+struct Elf32_RegInfo
+{
+    Elf32_Word ri_gprmask;
+    Elf32_Word[4] ri_cprmask;
+    Elf32_Sword ri_gp_value;
+}
+
+struct Elf_Options
+{
+    ubyte kind;
+    ubyte size;
+    Elf32_Section section;
+    Elf32_Word info;
+}
+
+enum ODK_NULL =        0;
+enum ODK_REGINFO =     1;
+enum ODK_EXCEPTIONS =  2;
+enum ODK_PAD =         3;
+enum ODK_HWPATCH =     4;
+enum ODK_FILL =        5;
+enum ODK_TAGS =        6;
+enum ODK_HWAND =       7;
+enum ODK_HWOR =        8;
+
+enum OEX_FPU_MIN =     0x1f;
+enum OEX_FPU_MAX =     0x1f00;
+enum OEX_PAGE0 =       0x10000;
+enum OEX_SMM =         0x20000;
+enum OEX_FPDBUG =      0x40000;
+enum OEX_PRECISEFP =   OEX_FPDBUG;
+enum OEX_DISMISS =     0x80000;
+
+enum OEX_FPU_INVAL =   0x10;
+enum OEX_FPU_DIV0 =    0x08;
+enum OEX_FPU_OFLO =    0x04;
+enum OEX_FPU_UFLO =    0x02;
+enum OEX_FPU_INEX =    0x01;
+
+enum OHW_R4KEOP =      0x1;
+enum OHW_R8KPFETCH =   0x2;
+enum OHW_R5KEOP =      0x4;
+enum OHW_R5KCVTL =     0x8;
+
+enum OPAD_PREFIX =     0x1;
+enum OPAD_POSTFIX =    0x2;
+enum OPAD_SYMBOL =     0x4;
+
+struct Elf_Options_Hw
+{
+    Elf32_Word hwp_flags1;
+    Elf32_Word hwp_flags2;
+}
+
+enum OHWA0_R4KEOP_CHECKED =    0x00000001;
+enum OHWA1_R4KEOP_CLEAN =      0x00000002;
+
+enum R_MIPS_NONE =             0;
+enum R_MIPS_16 =               1;
+enum R_MIPS_32 =               2;
+enum R_MIPS_REL32 =            3;
+enum R_MIPS_26 =               4;
+enum R_MIPS_HI16 =             5;
+enum R_MIPS_LO16 =             6;
+enum R_MIPS_GPREL16 =          7;
+enum R_MIPS_LITERAL =          8;
+enum R_MIPS_GOT16 =            9;
+enum R_MIPS_PC16 =             10;
+enum R_MIPS_CALL16 =           11;
+enum R_MIPS_GPREL32 =          12;
+
+enum R_MIPS_SHIFT5 =           16;
+enum R_MIPS_SHIFT6 =           17;
+enum R_MIPS_64 =               18;
+enum R_MIPS_GOT_DISP =         19;
+enum R_MIPS_GOT_PAGE =         20;
+enum R_MIPS_GOT_OFST =         21;
+enum R_MIPS_GOT_HI16 =         22;
+enum R_MIPS_GOT_LO16 =         23;
+enum R_MIPS_SUB =              24;
+enum R_MIPS_INSERT_A =         25;
+enum R_MIPS_INSERT_B =         26;
+enum R_MIPS_DELETE =           27;
+enum R_MIPS_HIGHER =           28;
+enum R_MIPS_HIGHEST =          29;
+enum R_MIPS_CALL_HI16 =        30;
+enum R_MIPS_CALL_LO16 =        31;
+enum R_MIPS_SCN_DISP =         32;
+enum R_MIPS_REL16 =            33;
+enum R_MIPS_ADD_IMMEDIATE =    34;
+enum R_MIPS_PJUMP =            35;
+enum R_MIPS_RELGOT =           36;
+enum R_MIPS_JALR =             37;
+enum R_MIPS_TLS_DTPMOD32 =     38;
+enum R_MIPS_TLS_DTPREL32 =     39;
+enum R_MIPS_TLS_DTPMOD64 =     40;
+enum R_MIPS_TLS_DTPREL64 =     41;
+enum R_MIPS_TLS_GD =           42;
+enum R_MIPS_TLS_LDM =          43;
+enum R_MIPS_TLS_DTPREL_HI16 =  44;
+enum R_MIPS_TLS_DTPREL_LO16 =  45;
+enum R_MIPS_TLS_GOTTPREL =     46;
+enum R_MIPS_TLS_TPREL32 =      47;
+enum R_MIPS_TLS_TPREL64 =      48;
+enum R_MIPS_TLS_TPREL_HI16 =   49;
+enum R_MIPS_TLS_TPREL_LO16 =   50;
+enum R_MIPS_GLOB_DAT =         51;
+enum R_MIPS_COPY =             126;
+enum R_MIPS_JUMP_SLOT =        127;
+enum R_MIPS_NUM =              128;
+
+enum PT_MIPS_REGINFO = 0x70000000;
+enum PT_MIPS_RTPROC =  0x70000001;
+enum PT_MIPS_OPTIONS = 0x70000002;
+
+enum PF_MIPS_LOCAL =   0x10000000;
+
+enum DT_MIPS_RLD_VERSION =  0x70000001;
+enum DT_MIPS_TIME_STAMP =   0x70000002;
+enum DT_MIPS_ICHECKSUM =    0x70000003;
+enum DT_MIPS_IVERSION =     0x70000004;
+enum DT_MIPS_FLAGS =        0x70000005;
+enum DT_MIPS_BASE_ADDRESS = 0x70000006;
+enum DT_MIPS_MSYM =         0x70000007;
+enum DT_MIPS_CONFLICT =     0x70000008;
+enum DT_MIPS_LIBLIST =      0x70000009;
+enum DT_MIPS_LOCAL_GOTNO =  0x7000000a;
+enum DT_MIPS_CONFLICTNO =   0x7000000b;
+enum DT_MIPS_LIBLISTNO =    0x70000010;
+enum DT_MIPS_SYMTABNO =     0x70000011;
+enum DT_MIPS_UNREFEXTNO =   0x70000012;
+enum DT_MIPS_GOTSYM =       0x70000013;
+enum DT_MIPS_HIPAGENO =     0x70000014;
+enum DT_MIPS_RLD_MAP =      0x70000016;
+enum DT_MIPS_DELTA_CLASS =  0x70000017;
+enum DT_MIPS_DELTA_CLASS_NO =    0x70000018;
+enum DT_MIPS_DELTA_INSTANCE =    0x70000019;
+enum DT_MIPS_DELTA_INSTANCE_NO = 0x7000001a;
+enum DT_MIPS_DELTA_RELOC =  0x7000001b;
+enum DT_MIPS_DELTA_RELOC_NO = 0x7000001c;
+enum DT_MIPS_DELTA_SYM =    0x7000001d;
+enum DT_MIPS_DELTA_SYM_NO = 0x7000001e;
+enum DT_MIPS_DELTA_CLASSSYM = 0x70000020;
+enum DT_MIPS_DELTA_CLASSSYM_NO = 0x70000021;
+enum DT_MIPS_CXX_FLAGS =    0x70000022;
+enum DT_MIPS_PIXIE_INIT =   0x70000023;
+enum DT_MIPS_SYMBOL_LIB =   0x70000024;
+enum DT_MIPS_LOCALPAGE_GOTIDX = 0x70000025;
+enum DT_MIPS_LOCAL_GOTIDX = 0x70000026;
+enum DT_MIPS_HIDDEN_GOTIDX = 0x70000027;
+enum DT_MIPS_PROTECTED_GOTIDX = 0x70000028;
+enum DT_MIPS_OPTIONS =      0x70000029;
+enum DT_MIPS_INTERFACE =    0x7000002a;
+enum DT_MIPS_DYNSTR_ALIGN = 0x7000002b;
+enum DT_MIPS_INTERFACE_SIZE = 0x7000002c;
+enum DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 0x7000002d;
+enum DT_MIPS_PERF_SUFFIX =  0x7000002e;
+enum DT_MIPS_COMPACT_SIZE = 0x7000002f;
+enum DT_MIPS_GP_VALUE =     0x70000030;
+enum DT_MIPS_AUX_DYNAMIC =  0x70000031;
+enum DT_MIPS_PLTGOT =       0x70000032;
+enum DT_MIPS_RWPLT =        0x70000034;
+enum DT_MIPS_NUM =          0x35;
+
+enum RHF_NONE =                   0;
+enum RHF_QUICKSTART =             (1 << 0);
+enum RHF_NOTPOT =                 (1 << 1);
+enum RHF_NO_LIBRARY_REPLACEMENT = (1 << 2);
+enum RHF_NO_MOVE =                (1 << 3);
+enum RHF_SGI_ONLY =               (1 << 4);
+enum RHF_GUARANTEE_INIT =         (1 << 5);
+enum RHF_DELTA_C_PLUS_PLUS =      (1 << 6);
+enum RHF_GUARANTEE_START_INIT =   (1 << 7);
+enum RHF_PIXIE =                  (1 << 8);
+enum RHF_DEFAULT_DELAY_LOAD =     (1 << 9);
+enum RHF_REQUICKSTART =           (1 << 10);
+enum RHF_REQUICKSTARTED =         (1 << 11);
+enum RHF_CORD =                   (1 << 12);
+enum RHF_NO_UNRES_UNDEF =         (1 << 13);
+enum RHF_RLD_ORDER_SAFE =         (1 << 14);
+
+struct Elf32_Lib
+{
+    Elf32_Word l_name;
+    Elf32_Word l_time_stamp;
+    Elf32_Word l_checksum;
+    Elf32_Word l_version;
+    Elf32_Word l_flags;
+}
+
+struct Elf64_Lib
+{
+    Elf64_Word l_name;
+    Elf64_Word l_time_stamp;
+    Elf64_Word l_checksum;
+    Elf64_Word l_version;
+    Elf64_Word l_flags;
+}
+
+enum LL_NONE =           0;
+enum LL_EXACT_MATCH =    (1 << 0);
+enum LL_IGNORE_INT_VER = (1 << 1);
+enum LL_REQUIRE_MINOR =  (1 << 2);
+enum LL_EXPORTS =        (1 << 3);
+enum LL_DELAY_LOAD =     (1 << 4);
+enum LL_DELTA =          (1 << 5);
+
+alias Elf32_Addr Elf32_Conflict;
+
+enum EF_PARISC_TRAPNIL =       0x00010000;
+enum EF_PARISC_EXT =           0x00020000;
+enum EF_PARISC_LSB =           0x00040000;
+enum EF_PARISC_WIDE =          0x00080000;
+enum EF_PARISC_NO_KABP =       0x00100000;
+enum EF_PARISC_LAZYSWAP =      0x00400000;
+enum EF_PARISC_ARCH =          0x0000ffff;
+
+enum EFA_PARISC_1_0 =              0x020b;
+enum EFA_PARISC_1_1 =              0x0210;
+enum EFA_PARISC_2_0 =              0x0214;
+
+enum SHN_PARISC_ANSI_COMMON =  0xff00;
+enum SHN_PARISC_HUGE_COMMON =  0xff01;
+
+enum SHT_PARISC_EXT =          0x70000000;
+enum SHT_PARISC_UNWIND =       0x70000001;
+enum SHT_PARISC_DOC =          0x70000002;
+
+enum SHF_PARISC_SHORT =        0x20000000;
+enum SHF_PARISC_HUGE =         0x40000000;
+enum SHF_PARISC_SBP =          0x80000000;
+
+enum STT_PARISC_MILLICODE =    13;
+
+enum STT_HP_OPAQUE =           (STT_LOOS + 0x1);
+enum STT_HP_STUB =             (STT_LOOS + 0x2);
+
+enum R_PARISC_NONE =           0;
+enum R_PARISC_DIR32 =          1;
+enum R_PARISC_DIR21L =         2;
+enum R_PARISC_DIR17R =         3;
+enum R_PARISC_DIR17F =         4;
+enum R_PARISC_DIR14R =         6;
+enum R_PARISC_PCREL32 =        9;
+enum R_PARISC_PCREL21L =       10;
+enum R_PARISC_PCREL17R =       11;
+enum R_PARISC_PCREL17F =       12;
+enum R_PARISC_PCREL14R =       14;
+enum R_PARISC_DPREL21L =       18;
+enum R_PARISC_DPREL14R =       22;
+enum R_PARISC_GPREL21L =       26;
+enum R_PARISC_GPREL14R =       30;
+enum R_PARISC_LTOFF21L =       34;
+enum R_PARISC_LTOFF14R =       38;
+enum R_PARISC_SECREL32 =       41;
+enum R_PARISC_SEGBASE =        48;
+enum R_PARISC_SEGREL32 =       49;
+enum R_PARISC_PLTOFF21L =      50;
+enum R_PARISC_PLTOFF14R =      54;
+enum R_PARISC_LTOFF_FPTR32 =   57;
+enum R_PARISC_LTOFF_FPTR21L =  58;
+enum R_PARISC_LTOFF_FPTR14R =  62;
+enum R_PARISC_FPTR64 =         64;
+enum R_PARISC_PLABEL32 =       65;
+enum R_PARISC_PLABEL21L =      66;
+enum R_PARISC_PLABEL14R =      70;
+enum R_PARISC_PCREL64 =        72;
+enum R_PARISC_PCREL22F =       74;
+enum R_PARISC_PCREL14WR =      75;
+enum R_PARISC_PCREL14DR =      76;
+enum R_PARISC_PCREL16F =       77;
+enum R_PARISC_PCREL16WF =      78;
+enum R_PARISC_PCREL16DF =      79;
+enum R_PARISC_DIR64 =          80;
+enum R_PARISC_DIR14WR =        83;
+enum R_PARISC_DIR14DR =        84;
+enum R_PARISC_DIR16F =         85;
+enum R_PARISC_DIR16WF =        86;
+enum R_PARISC_DIR16DF =        87;
+enum R_PARISC_GPREL64 =        88;
+enum R_PARISC_GPREL14WR =      91;
+enum R_PARISC_GPREL14DR =      92;
+enum R_PARISC_GPREL16F =       93;
+enum R_PARISC_GPREL16WF =      94;
+enum R_PARISC_GPREL16DF =      95;
+enum R_PARISC_LTOFF64 =        96;
+enum R_PARISC_LTOFF14WR =      99;
+enum R_PARISC_LTOFF14DR =      100;
+enum R_PARISC_LTOFF16F =       101;
+enum R_PARISC_LTOFF16WF =      102;
+enum R_PARISC_LTOFF16DF =      103;
+enum R_PARISC_SECREL64 =       104;
+enum R_PARISC_SEGREL64 =       112;
+enum R_PARISC_PLTOFF14WR =     115;
+enum R_PARISC_PLTOFF14DR =     116;
+enum R_PARISC_PLTOFF16F =      117;
+enum R_PARISC_PLTOFF16WF =     118;
+enum R_PARISC_PLTOFF16DF =     119;
+enum R_PARISC_LTOFF_FPTR64 =   120;
+enum R_PARISC_LTOFF_FPTR14WR = 123;
+enum R_PARISC_LTOFF_FPTR14DR = 124;
+enum R_PARISC_LTOFF_FPTR16F =  125;
+enum R_PARISC_LTOFF_FPTR16WF = 126;
+enum R_PARISC_LTOFF_FPTR16DF = 127;
+enum R_PARISC_LORESERVE =      128;
+enum R_PARISC_COPY =           128;
+enum R_PARISC_IPLT =           129;
+enum R_PARISC_EPLT =           130;
+enum R_PARISC_TPREL32 =        153;
+enum R_PARISC_TPREL21L =       154;
+enum R_PARISC_TPREL14R =       158;
+enum R_PARISC_LTOFF_TP21L =    162;
+enum R_PARISC_LTOFF_TP14R =    166;
+enum R_PARISC_LTOFF_TP14F =    167;
+enum R_PARISC_TPREL64 =        216;
+enum R_PARISC_TPREL14WR =      219;
+enum R_PARISC_TPREL14DR =      220;
+enum R_PARISC_TPREL16F =       221;
+enum R_PARISC_TPREL16WF =      222;
+enum R_PARISC_TPREL16DF =      223;
+enum R_PARISC_LTOFF_TP64 =     224;
+enum R_PARISC_LTOFF_TP14WR =   227;
+enum R_PARISC_LTOFF_TP14DR =   228;
+enum R_PARISC_LTOFF_TP16F =    229;
+enum R_PARISC_LTOFF_TP16WF =   230;
+enum R_PARISC_LTOFF_TP16DF =   231;
+enum R_PARISC_GNU_VTENTRY =    232;
+enum R_PARISC_GNU_VTINHERIT =  233;
+enum R_PARISC_TLS_GD21L =      234;
+enum R_PARISC_TLS_GD14R =      235;
+enum R_PARISC_TLS_GDCALL =     236;
+enum R_PARISC_TLS_LDM21L =     237;
+enum R_PARISC_TLS_LDM14R =     238;
+enum R_PARISC_TLS_LDMCALL =    239;
+enum R_PARISC_TLS_LDO21L =     240;
+enum R_PARISC_TLS_LDO14R =     241;
+enum R_PARISC_TLS_DTPMOD32 =   242;
+enum R_PARISC_TLS_DTPMOD64 =   243;
+enum R_PARISC_TLS_DTPOFF32 =   244;
+enum R_PARISC_TLS_DTPOFF64 =   245;
+enum R_PARISC_TLS_LE21L =      R_PARISC_TPREL21L;
+enum R_PARISC_TLS_LE14R =      R_PARISC_TPREL14R;
+enum R_PARISC_TLS_IE21L =      R_PARISC_LTOFF_TP21L;
+enum R_PARISC_TLS_IE14R =      R_PARISC_LTOFF_TP14R;
+enum R_PARISC_TLS_TPREL32 =    R_PARISC_TPREL32;
+enum R_PARISC_TLS_TPREL64 =    R_PARISC_TPREL64;
+enum R_PARISC_HIRESERVE =      255;
+
+enum PT_HP_TLS =               (PT_LOOS + 0x0);
+enum PT_HP_CORE_NONE =         (PT_LOOS + 0x1);
+enum PT_HP_CORE_VERSION =      (PT_LOOS + 0x2);
+enum PT_HP_CORE_KERNEL =       (PT_LOOS + 0x3);
+enum PT_HP_CORE_COMM =         (PT_LOOS + 0x4);
+enum PT_HP_CORE_PROC =         (PT_LOOS + 0x5);
+enum PT_HP_CORE_LOADABLE =     (PT_LOOS + 0x6);
+enum PT_HP_CORE_STACK =        (PT_LOOS + 0x7);
+enum PT_HP_CORE_SHM =          (PT_LOOS + 0x8);
+enum PT_HP_CORE_MMF =          (PT_LOOS + 0x9);
+enum PT_HP_PARALLEL =          (PT_LOOS + 0x10);
+enum PT_HP_FASTBIND =          (PT_LOOS + 0x11);
+enum PT_HP_OPT_ANNOT =         (PT_LOOS + 0x12);
+enum PT_HP_HSL_ANNOT =         (PT_LOOS + 0x13);
+enum PT_HP_STACK =             (PT_LOOS + 0x14);
+
+enum PT_PARISC_ARCHEXT =       0x70000000;
+enum PT_PARISC_UNWIND =        0x70000001;
+
+enum PF_PARISC_SBP =           0x08000000;
+
+enum PF_HP_PAGE_SIZE =         0x00100000;
+enum PF_HP_FAR_SHARED =        0x00200000;
+enum PF_HP_NEAR_SHARED =       0x00400000;
+enum PF_HP_CODE =              0x01000000;
+enum PF_HP_MODIFY =            0x02000000;
+enum PF_HP_LAZYSWAP =          0x04000000;
+enum PF_HP_SBP =               0x08000000;
+
+enum EF_ALPHA_32BIT =          1;
+enum EF_ALPHA_CANRELAX =       2;
+enum SHT_ALPHA_DEBUG =         0x70000001;
+enum SHT_ALPHA_REGINFO =       0x70000002;
+
+enum SHF_ALPHA_GPREL =         0x10000000;
+enum STO_ALPHA_NOPV =          0x80;
+enum STO_ALPHA_STD_GPLOAD =    0x88;
+
+enum R_ALPHA_NONE =            0;
+enum R_ALPHA_REFLONG =         1;
+enum R_ALPHA_REFQUAD =         2;
+enum R_ALPHA_GPREL32 =         3;
+enum R_ALPHA_LITERAL =         4;
+enum R_ALPHA_LITUSE =          5;
+enum R_ALPHA_GPDISP =          6;
+enum R_ALPHA_BRADDR =          7;
+enum R_ALPHA_HINT =            8;
+enum R_ALPHA_SREL16 =          9;
+enum R_ALPHA_SREL32 =          10;
+enum R_ALPHA_SREL64 =          11;
+enum R_ALPHA_GPRELHIGH =       17;
+enum R_ALPHA_GPRELLOW =        18;
+enum R_ALPHA_GPREL16 =         19;
+enum R_ALPHA_COPY =            24;
+enum R_ALPHA_GLOB_DAT =        25;
+enum R_ALPHA_JMP_SLOT =        26;
+enum R_ALPHA_RELATIVE =        27;
+enum R_ALPHA_TLS_GD_HI =       28;
+enum R_ALPHA_TLSGD =           29;
+enum R_ALPHA_TLS_LDM =         30;
+enum R_ALPHA_DTPMOD64 =        31;
+enum R_ALPHA_GOTDTPREL =       32;
+enum R_ALPHA_DTPREL64 =        33;
+enum R_ALPHA_DTPRELHI =        34;
+enum R_ALPHA_DTPRELLO =        35;
+enum R_ALPHA_DTPREL16 =        36;
+enum R_ALPHA_GOTTPREL =        37;
+enum R_ALPHA_TPREL64 =         38;
+enum R_ALPHA_TPRELHI =         39;
+enum R_ALPHA_TPRELLO =         40;
+enum R_ALPHA_TPREL16 =         41;
+enum R_ALPHA_NUM =             46;
+enum LITUSE_ALPHA_ADDR =       0;
+enum LITUSE_ALPHA_BASE =       1;
+enum LITUSE_ALPHA_BYTOFF =     2;
+enum LITUSE_ALPHA_JSR =        3;
+enum LITUSE_ALPHA_TLS_GD =     4;
+enum LITUSE_ALPHA_TLS_LDM =    5;
+enum DT_ALPHA_PLTRO =          (DT_LOPROC + 0);
+enum DT_ALPHA_NUM =            1;
+enum EF_PPC_EMB =              0x80000000;
+enum EF_PPC_RELOCATABLE =      0x00010000;
+enum EF_PPC_RELOCATABLE_LIB =  0x00008000;
+enum R_PPC_NONE =              0;
+enum R_PPC_ADDR32 =            1;
+enum R_PPC_ADDR24 =            2;
+enum R_PPC_ADDR16 =            3;
+enum R_PPC_ADDR16_LO =         4;
+enum R_PPC_ADDR16_HI =         5;
+enum R_PPC_ADDR16_HA =         6;
+enum R_PPC_ADDR14 =            7;
+enum R_PPC_ADDR14_BRTAKEN =    8;
+enum R_PPC_ADDR14_BRNTAKEN =   9;
+enum R_PPC_REL24 =             10;
+enum R_PPC_REL14 =             11;
+enum R_PPC_REL14_BRTAKEN =     12;
+enum R_PPC_REL14_BRNTAKEN =    13;
+enum R_PPC_GOT16 =             14;
+enum R_PPC_GOT16_LO =          15;
+enum R_PPC_GOT16_HI =          16;
+enum R_PPC_GOT16_HA =          17;
+enum R_PPC_PLTREL24 =          18;
+enum R_PPC_COPY =              19;
+enum R_PPC_GLOB_DAT =          20;
+enum R_PPC_JMP_SLOT =          21;
+enum R_PPC_RELATIVE =          22;
+enum R_PPC_LOCAL24PC =         23;
+enum R_PPC_UADDR32 =           24;
+enum R_PPC_UADDR16 =           25;
+enum R_PPC_REL32 =             26;
+enum R_PPC_PLT32 =             27;
+enum R_PPC_PLTREL32 =          28;
+enum R_PPC_PLT16_LO =          29;
+enum R_PPC_PLT16_HI =          30;
+enum R_PPC_PLT16_HA =          31;
+enum R_PPC_SDAREL16 =          32;
+enum R_PPC_SECTOFF =           33;
+enum R_PPC_SECTOFF_LO =        34;
+enum R_PPC_SECTOFF_HI =        35;
+enum R_PPC_SECTOFF_HA =        36;
+enum R_PPC_TLS =               67;
+enum R_PPC_DTPMOD32 =          68;
+enum R_PPC_TPREL16 =           69;
+enum R_PPC_TPREL16_LO =        70;
+enum R_PPC_TPREL16_HI =        71;
+enum R_PPC_TPREL16_HA =        72;
+enum R_PPC_TPREL32 =           73;
+enum R_PPC_DTPREL16 =          74;
+enum R_PPC_DTPREL16_LO =       75;
+enum R_PPC_DTPREL16_HI =       76;
+enum R_PPC_DTPREL16_HA =       77;
+enum R_PPC_DTPREL32 =          78;
+enum R_PPC_GOT_TLSGD16 =       79;
+enum R_PPC_GOT_TLSGD16_LO =    80;
+enum R_PPC_GOT_TLSGD16_HI =    81;
+enum R_PPC_GOT_TLSGD16_HA =    82;
+enum R_PPC_GOT_TLSLD16 =       83;
+enum R_PPC_GOT_TLSLD16_LO =    84;
+enum R_PPC_GOT_TLSLD16_HI =    85;
+enum R_PPC_GOT_TLSLD16_HA =    86;
+enum R_PPC_GOT_TPREL16 =       87;
+enum R_PPC_GOT_TPREL16_LO =    88;
+enum R_PPC_GOT_TPREL16_HI =    89;
+enum R_PPC_GOT_TPREL16_HA =    90;
+enum R_PPC_GOT_DTPREL16 =      91;
+enum R_PPC_GOT_DTPREL16_LO =   92;
+enum R_PPC_GOT_DTPREL16_HI =   93;
+enum R_PPC_GOT_DTPREL16_HA =   94;
+enum R_PPC_EMB_NADDR32 =       101;
+enum R_PPC_EMB_NADDR16 =       102;
+enum R_PPC_EMB_NADDR16_LO =    103;
+enum R_PPC_EMB_NADDR16_HI =    104;
+enum R_PPC_EMB_NADDR16_HA =    105;
+enum R_PPC_EMB_SDAI16 =        106;
+enum R_PPC_EMB_SDA2I16 =       107;
+enum R_PPC_EMB_SDA2REL =       108;
+enum R_PPC_EMB_SDA21 =         109;
+enum R_PPC_EMB_MRKREF =        110;
+enum R_PPC_EMB_RELSEC16 =      111;
+enum R_PPC_EMB_RELST_LO =      112;
+enum R_PPC_EMB_RELST_HI =      113;
+enum R_PPC_EMB_RELST_HA =      114;
+enum R_PPC_EMB_BIT_FLD =       115;
+enum R_PPC_EMB_RELSDA =        116;
+enum R_PPC_DIAB_SDA21_LO =     180;
+enum R_PPC_DIAB_SDA21_HI =     181;
+enum R_PPC_DIAB_SDA21_HA =     182;
+enum R_PPC_DIAB_RELSDA_LO =    183;
+enum R_PPC_DIAB_RELSDA_HI =    184;
+enum R_PPC_DIAB_RELSDA_HA =    185;
+enum R_PPC_IRELATIVE =         248;
+enum R_PPC_REL16 =             249;
+enum R_PPC_REL16_LO =          250;
+enum R_PPC_REL16_HI =          251;
+enum R_PPC_REL16_HA =          252;
+enum R_PPC_TOC16 =             255;
+enum DT_PPC_GOT =              (DT_LOPROC + 0);
+enum DT_PPC_NUM =              1;
+enum R_PPC64_NONE =            R_PPC_NONE;
+enum R_PPC64_ADDR32 =          R_PPC_ADDR32;
+enum R_PPC64_ADDR24 =          R_PPC_ADDR24;
+enum R_PPC64_ADDR16 =          R_PPC_ADDR16;
+enum R_PPC64_ADDR16_LO =       R_PPC_ADDR16_LO;
+enum R_PPC64_ADDR16_HI =       R_PPC_ADDR16_HI;
+enum R_PPC64_ADDR16_HA =       R_PPC_ADDR16_HA;
+enum R_PPC64_ADDR14 =          R_PPC_ADDR14;
+enum R_PPC64_ADDR14_BRTAKEN =  R_PPC_ADDR14_BRTAKEN;
+enum R_PPC64_ADDR14_BRNTAKEN = R_PPC_ADDR14_BRNTAKEN;
+enum R_PPC64_REL24 =           R_PPC_REL24;
+enum R_PPC64_REL14 =           R_PPC_REL14;
+enum R_PPC64_REL14_BRTAKEN =   R_PPC_REL14_BRTAKEN;
+enum R_PPC64_REL14_BRNTAKEN =  R_PPC_REL14_BRNTAKEN;
+enum R_PPC64_GOT16 =           R_PPC_GOT16;
+enum R_PPC64_GOT16_LO =        R_PPC_GOT16_LO;
+enum R_PPC64_GOT16_HI =        R_PPC_GOT16_HI;
+enum R_PPC64_GOT16_HA =        R_PPC_GOT16_HA;
+
+enum R_PPC64_COPY =            R_PPC_COPY;
+enum R_PPC64_GLOB_DAT =        R_PPC_GLOB_DAT;
+enum R_PPC64_JMP_SLOT =        R_PPC_JMP_SLOT;
+enum R_PPC64_RELATIVE =        R_PPC_RELATIVE;
+
+enum R_PPC64_UADDR32 =         R_PPC_UADDR32;
+enum R_PPC64_UADDR16 =         R_PPC_UADDR16;
+enum R_PPC64_REL32 =           R_PPC_REL32;
+enum R_PPC64_PLT32 =           R_PPC_PLT32;
+enum R_PPC64_PLTREL32 =        R_PPC_PLTREL32;
+enum R_PPC64_PLT16_LO =        R_PPC_PLT16_LO;
+enum R_PPC64_PLT16_HI =        R_PPC_PLT16_HI;
+enum R_PPC64_PLT16_HA =        R_PPC_PLT16_HA;
+
+enum R_PPC64_SECTOFF =         R_PPC_SECTOFF;
+enum R_PPC64_SECTOFF_LO =      R_PPC_SECTOFF_LO;
+enum R_PPC64_SECTOFF_HI =      R_PPC_SECTOFF_HI;
+enum R_PPC64_SECTOFF_HA =      R_PPC_SECTOFF_HA;
+enum R_PPC64_ADDR30 =          37;
+enum R_PPC64_ADDR64 =          38;
+enum R_PPC64_ADDR16_HIGHER =   39;
+enum R_PPC64_ADDR16_HIGHERA =  40;
+enum R_PPC64_ADDR16_HIGHEST =  41;
+enum R_PPC64_ADDR16_HIGHESTA = 42;
+enum R_PPC64_UADDR64 =         43;
+enum R_PPC64_REL64 =           44;
+enum R_PPC64_PLT64 =           45;
+enum R_PPC64_PLTREL64 =        46;
+enum R_PPC64_TOC16 =           47;
+enum R_PPC64_TOC16_LO =        48;
+enum R_PPC64_TOC16_HI =        49;
+enum R_PPC64_TOC16_HA =        50;
+enum R_PPC64_TOC =             51;
+enum R_PPC64_PLTGOT16 =        52;
+enum R_PPC64_PLTGOT16_LO =     53;
+enum R_PPC64_PLTGOT16_HI =     54;
+enum R_PPC64_PLTGOT16_HA =     55;
+
+enum R_PPC64_ADDR16_DS =       56;
+enum R_PPC64_ADDR16_LO_DS =    57;
+enum R_PPC64_GOT16_DS =        58;
+enum R_PPC64_GOT16_LO_DS =     59;
+enum R_PPC64_PLT16_LO_DS =     60;
+enum R_PPC64_SECTOFF_DS =      61;
+enum R_PPC64_SECTOFF_LO_DS =   62;
+enum R_PPC64_TOC16_DS =        63;
+enum R_PPC64_TOC16_LO_DS =     64;
+enum R_PPC64_PLTGOT16_DS =     65;
+enum R_PPC64_PLTGOT16_LO_DS =  66;
+enum R_PPC64_TLS =             67;
+enum R_PPC64_DTPMOD64 =        68;
+enum R_PPC64_TPREL16 =         69;
+enum R_PPC64_TPREL16_LO =      70;
+enum R_PPC64_TPREL16_HI =      71;
+enum R_PPC64_TPREL16_HA =      72;
+enum R_PPC64_TPREL64 =         73;
+enum R_PPC64_DTPREL16 =        74;
+enum R_PPC64_DTPREL16_LO =     75;
+enum R_PPC64_DTPREL16_HI =     76;
+enum R_PPC64_DTPREL16_HA =     77;
+enum R_PPC64_DTPREL64 =        78;
+enum R_PPC64_GOT_TLSGD16 =     79;
+enum R_PPC64_GOT_TLSGD16_LO =  80;
+enum R_PPC64_GOT_TLSGD16_HI =  81;
+enum R_PPC64_GOT_TLSGD16_HA =  82;
+enum R_PPC64_GOT_TLSLD16 =     83;
+enum R_PPC64_GOT_TLSLD16_LO =  84;
+enum R_PPC64_GOT_TLSLD16_HI =  85;
+enum R_PPC64_GOT_TLSLD16_HA =  86;
+enum R_PPC64_GOT_TPREL16_DS =  87;
+enum R_PPC64_GOT_TPREL16_LO_DS = 88;
+enum R_PPC64_GOT_TPREL16_HI =  89;
+enum R_PPC64_GOT_TPREL16_HA =  90;
+enum R_PPC64_GOT_DTPREL16_DS = 91;
+enum R_PPC64_GOT_DTPREL16_LO_DS = 92;
+enum R_PPC64_GOT_DTPREL16_HI = 93;
+enum R_PPC64_GOT_DTPREL16_HA = 94;
+enum R_PPC64_TPREL16_DS =      95;
+enum R_PPC64_TPREL16_LO_DS =   96;
+enum R_PPC64_TPREL16_HIGHER =  97;
+enum R_PPC64_TPREL16_HIGHERA = 98;
+enum R_PPC64_TPREL16_HIGHEST = 99;
+enum R_PPC64_TPREL16_HIGHESTA = 100;
+enum R_PPC64_DTPREL16_DS =     101;
+enum R_PPC64_DTPREL16_LO_DS =  102;
+enum R_PPC64_DTPREL16_HIGHER = 103;
+enum R_PPC64_DTPREL16_HIGHERA = 104;
+enum R_PPC64_DTPREL16_HIGHEST = 105;
+enum R_PPC64_DTPREL16_HIGHESTA = 106;
+enum R_PPC64_JMP_IREL =        247;
+enum R_PPC64_IRELATIVE =       248;
+enum R_PPC64_REL16 =           249;
+enum R_PPC64_REL16_LO =        250;
+enum R_PPC64_REL16_HI =        251;
+enum R_PPC64_REL16_HA =        252;
+enum DT_PPC64_GLINK =  (DT_LOPROC + 0);
+enum DT_PPC64_OPD =    (DT_LOPROC + 1);
+enum DT_PPC64_OPDSZ =  (DT_LOPROC + 2);
+enum DT_PPC64_NUM =    3;
+enum EF_ARM_RELEXEC =          0x01;
+enum EF_ARM_HASENTRY =         0x02;
+enum EF_ARM_INTERWORK =        0x04;
+enum EF_ARM_APCS_26 =          0x08;
+enum EF_ARM_APCS_FLOAT =       0x10;
+enum EF_ARM_PIC =              0x20;
+enum EF_ARM_ALIGN8 =           0x40;
+enum EF_ARM_NEW_ABI =          0x80;
+enum EF_ARM_OLD_ABI =          0x100;
+enum EF_ARM_SOFT_FLOAT =       0x200;
+enum EF_ARM_VFP_FLOAT =        0x400;
+enum EF_ARM_MAVERICK_FLOAT =   0x800;
+
+enum EF_ARM_ABI_FLOAT_SOFT =   0x200;
+enum EF_ARM_ABI_FLOAT_HARD =   0x400;
+enum EF_ARM_SYMSARESORTED =    0x04;
+enum EF_ARM_DYNSYMSUSESEGIDX = 0x08;
+enum EF_ARM_MAPSYMSFIRST =     0x10;
+enum EF_ARM_EABIMASK =         0XFF000000;
+enum EF_ARM_BE8 =          0x00800000;
+enum EF_ARM_LE8 =          0x00400000;
+
+extern (D) auto EF_ARM_EABI_VERSION(F)(F flags) { return flags & EF_ARM_EABIMASK; }
+enum EF_ARM_EABI_UNKNOWN =     0x00000000;
+enum EF_ARM_EABI_VER1 =        0x01000000;
+enum EF_ARM_EABI_VER2 =        0x02000000;
+enum EF_ARM_EABI_VER3 =        0x03000000;
+enum EF_ARM_EABI_VER4 =        0x04000000;
+enum EF_ARM_EABI_VER5 =        0x05000000;
+enum STT_ARM_TFUNC =           STT_LOPROC;
+enum STT_ARM_16BIT =           STT_HIPROC;
+enum SHF_ARM_ENTRYSECT =       0x10000000;
+enum SHF_ARM_COMDEF =          0x80000000;
+enum PF_ARM_SB =               0x10000000;
+enum PF_ARM_PI =               0x20000000;
+enum PF_ARM_ABS =              0x40000000;
+enum PT_ARM_EXIDX =            (PT_LOPROC + 1);
+enum SHT_ARM_EXIDX =           (SHT_LOPROC + 1);
+enum SHT_ARM_PREEMPTMAP =      (SHT_LOPROC + 2);
+enum SHT_ARM_ATTRIBUTES =      (SHT_LOPROC + 3);
+
+enum R_AARCH64_NONE =            0;
+enum R_AARCH64_ABS64 =         257;
+enum R_AARCH64_ABS32 =         258;
+enum R_AARCH64_COPY =         1024;
+enum R_AARCH64_GLOB_DAT =     1025;
+enum R_AARCH64_JUMP_SLOT =    1026;
+enum R_AARCH64_RELATIVE =     1027;
+enum R_AARCH64_TLS_DTPMOD64 = 1028;
+enum R_AARCH64_TLS_DTPREL64 = 1029;
+enum R_AARCH64_TLS_TPREL64 =  1030;
+enum R_AARCH64_TLSDESC =      1031;
+
+enum R_ARM_NONE =              0;
+enum R_ARM_PC24 =              1;
+enum R_ARM_ABS32 =             2;
+enum R_ARM_REL32 =             3;
+enum R_ARM_PC13 =              4;
+enum R_ARM_ABS16 =             5;
+enum R_ARM_ABS12 =             6;
+enum R_ARM_THM_ABS5 =          7;
+enum R_ARM_ABS8 =              8;
+enum R_ARM_SBREL32 =           9;
+enum R_ARM_THM_PC22 =          10;
+enum R_ARM_THM_PC8 =           11;
+enum R_ARM_AMP_VCALL9 =        12;
+enum R_ARM_SWI24 =             13;
+enum R_ARM_TLS_DESC =          13;
+enum R_ARM_THM_SWI8 =          14;
+enum R_ARM_XPC25 =             15;
+enum R_ARM_THM_XPC22 =         16;
+enum R_ARM_TLS_DTPMOD32 =      17;
+enum R_ARM_TLS_DTPOFF32 =      18;
+enum R_ARM_TLS_TPOFF32 =       19;
+enum R_ARM_COPY =              20;
+enum R_ARM_GLOB_DAT =          21;
+enum R_ARM_JUMP_SLOT =         22;
+enum R_ARM_RELATIVE =          23;
+enum R_ARM_GOTOFF =            24;
+enum R_ARM_GOTPC =             25;
+enum R_ARM_GOT32 =             26;
+enum R_ARM_PLT32 =             27;
+enum R_ARM_ALU_PCREL_7_0 =     32;
+enum R_ARM_ALU_PCREL_15_8 =    33;
+enum R_ARM_ALU_PCREL_23_15 =   34;
+enum R_ARM_LDR_SBREL_11_0 =    35;
+enum R_ARM_ALU_SBREL_19_12 =   36;
+enum R_ARM_ALU_SBREL_27_20 =   37;
+enum R_ARM_TLS_GOTDESC =       90;
+enum R_ARM_TLS_CALL =          91;
+enum R_ARM_TLS_DESCSEQ =       92;
+enum R_ARM_THM_TLS_CALL =      93;
+enum R_ARM_GNU_VTENTRY =       100;
+enum R_ARM_GNU_VTINHERIT =     101;
+enum R_ARM_THM_PC11 =          102;
+enum R_ARM_THM_PC9 =           103;
+enum R_ARM_TLS_GD32 =          104;
+enum R_ARM_TLS_LDM32 =         105;
+enum R_ARM_TLS_LDO32 =         106;
+enum R_ARM_TLS_IE32 =          107;
+enum R_ARM_TLS_LE32 =          108;
+enum R_ARM_THM_TLS_DESCSEQ =   129;
+enum R_ARM_IRELATIVE =         160;
+enum R_ARM_RXPC25 =            249;
+enum R_ARM_RSBREL32 =          250;
+enum R_ARM_THM_RPC22 =         251;
+enum R_ARM_RREL32 =            252;
+enum R_ARM_RABS22 =            253;
+enum R_ARM_RPC24 =             254;
+enum R_ARM_RBASE =             255;
+enum R_ARM_NUM =               256;
+enum EF_IA_64_MASKOS =         0x0000000f;
+enum EF_IA_64_ABI64 =          0x00000010;
+enum EF_IA_64_ARCH =           0xff000000;
+enum PT_IA_64_ARCHEXT =        (PT_LOPROC + 0);
+enum PT_IA_64_UNWIND =         (PT_LOPROC + 1);
+enum PT_IA_64_HP_OPT_ANOT =    (PT_LOOS + 0x12);
+enum PT_IA_64_HP_HSL_ANOT =    (PT_LOOS + 0x13);
+enum PT_IA_64_HP_STACK =       (PT_LOOS + 0x14);
+enum PF_IA_64_NORECOV =        0x80000000;
+enum SHT_IA_64_EXT =           (SHT_LOPROC + 0);
+enum SHT_IA_64_UNWIND =        (SHT_LOPROC + 1);
+enum SHF_IA_64_SHORT =         0x10000000;
+enum SHF_IA_64_NORECOV =       0x20000000;
+enum DT_IA_64_PLT_RESERVE =    (DT_LOPROC + 0);
+enum DT_IA_64_NUM =            1;
+enum R_IA64_NONE =             0x00;
+enum R_IA64_IMM14 =            0x21;
+enum R_IA64_IMM22 =            0x22;
+enum R_IA64_IMM64 =            0x23;
+enum R_IA64_DIR32MSB =         0x24;
+enum R_IA64_DIR32LSB =         0x25;
+enum R_IA64_DIR64MSB =         0x26;
+enum R_IA64_DIR64LSB =         0x27;
+enum R_IA64_GPREL22 =          0x2a;
+enum R_IA64_GPREL64I =         0x2b;
+enum R_IA64_GPREL32MSB =       0x2c;
+enum R_IA64_GPREL32LSB =       0x2d;
+enum R_IA64_GPREL64MSB =       0x2e;
+enum R_IA64_GPREL64LSB =       0x2f;
+enum R_IA64_LTOFF22 =          0x32;
+enum R_IA64_LTOFF64I =         0x33;
+enum R_IA64_PLTOFF22 =         0x3a;
+enum R_IA64_PLTOFF64I =        0x3b;
+enum R_IA64_PLTOFF64MSB =      0x3e;
+enum R_IA64_PLTOFF64LSB =      0x3f;
+enum R_IA64_FPTR64I =          0x43;
+enum R_IA64_FPTR32MSB =        0x44;
+enum R_IA64_FPTR32LSB =        0x45;
+enum R_IA64_FPTR64MSB =        0x46;
+enum R_IA64_FPTR64LSB =        0x47;
+enum R_IA64_PCREL60B =         0x48;
+enum R_IA64_PCREL21B =         0x49;
+enum R_IA64_PCREL21M =         0x4a;
+enum R_IA64_PCREL21F =         0x4b;
+enum R_IA64_PCREL32MSB =       0x4c;
+enum R_IA64_PCREL32LSB =       0x4d;
+enum R_IA64_PCREL64MSB =       0x4e;
+enum R_IA64_PCREL64LSB =       0x4f;
+enum R_IA64_LTOFF_FPTR22 =     0x52;
+enum R_IA64_LTOFF_FPTR64I =    0x53;
+enum R_IA64_LTOFF_FPTR32MSB =  0x54;
+enum R_IA64_LTOFF_FPTR32LSB =  0x55;
+enum R_IA64_LTOFF_FPTR64MSB =  0x56;
+enum R_IA64_LTOFF_FPTR64LSB =  0x57;
+enum R_IA64_SEGREL32MSB =      0x5c;
+enum R_IA64_SEGREL32LSB =      0x5d;
+enum R_IA64_SEGREL64MSB =      0x5e;
+enum R_IA64_SEGREL64LSB =      0x5f;
+enum R_IA64_SECREL32MSB =      0x64;
+enum R_IA64_SECREL32LSB =      0x65;
+enum R_IA64_SECREL64MSB =      0x66;
+enum R_IA64_SECREL64LSB =      0x67;
+enum R_IA64_REL32MSB =         0x6c;
+enum R_IA64_REL32LSB =         0x6d;
+enum R_IA64_REL64MSB =         0x6e;
+enum R_IA64_REL64LSB =         0x6f;
+enum R_IA64_LTV32MSB =         0x74;
+enum R_IA64_LTV32LSB =         0x75;
+enum R_IA64_LTV64MSB =         0x76;
+enum R_IA64_LTV64LSB =         0x77;
+enum R_IA64_PCREL21BI =        0x79;
+enum R_IA64_PCREL22 =          0x7a;
+enum R_IA64_PCREL64I =         0x7b;
+enum R_IA64_IPLTMSB =          0x80;
+enum R_IA64_IPLTLSB =          0x81;
+enum R_IA64_COPY =             0x84;
+enum R_IA64_SUB =              0x85;
+enum R_IA64_LTOFF22X =         0x86;
+enum R_IA64_LDXMOV =           0x87;
+enum R_IA64_TPREL14 =          0x91;
+enum R_IA64_TPREL22 =          0x92;
+enum R_IA64_TPREL64I =         0x93;
+enum R_IA64_TPREL64MSB =       0x96;
+enum R_IA64_TPREL64LSB =       0x97;
+enum R_IA64_LTOFF_TPREL22 =    0x9a;
+enum R_IA64_DTPMOD64MSB =      0xa6;
+enum R_IA64_DTPMOD64LSB =      0xa7;
+enum R_IA64_LTOFF_DTPMOD22 =   0xaa;
+enum R_IA64_DTPREL14 =         0xb1;
+enum R_IA64_DTPREL22 =         0xb2;
+enum R_IA64_DTPREL64I =        0xb3;
+enum R_IA64_DTPREL32MSB =      0xb4;
+enum R_IA64_DTPREL32LSB =      0xb5;
+enum R_IA64_DTPREL64MSB =      0xb6;
+enum R_IA64_DTPREL64LSB =      0xb7;
+enum R_IA64_LTOFF_DTPREL22 =   0xba;
+enum EF_SH_MACH_MASK =         0x1f;
+enum EF_SH_UNKNOWN =           0x0;
+enum EF_SH1 =                  0x1;
+enum EF_SH2 =                  0x2;
+enum EF_SH3 =                  0x3;
+enum EF_SH_DSP =               0x4;
+enum EF_SH3_DSP =              0x5;
+enum EF_SH4AL_DSP =            0x6;
+enum EF_SH3E =                 0x8;
+enum EF_SH4 =                  0x9;
+enum EF_SH2E =                 0xb;
+enum EF_SH4A =                 0xc;
+enum EF_SH2A =                 0xd;
+enum EF_SH4_NOFPU =            0x10;
+enum EF_SH4A_NOFPU =           0x11;
+enum EF_SH4_NOMMU_NOFPU =      0x12;
+enum EF_SH2A_NOFPU =           0x13;
+enum EF_SH3_NOMMU =            0x14;
+enum EF_SH2A_SH4_NOFPU =       0x15;
+enum EF_SH2A_SH3_NOFPU =       0x16;
+enum EF_SH2A_SH4 =             0x17;
+enum EF_SH2A_SH3E =            0x18;
+enum R_SH_NONE =               0;
+enum R_SH_DIR32 =              1;
+enum R_SH_REL32 =              2;
+enum R_SH_DIR8WPN =            3;
+enum R_SH_IND12W =             4;
+enum R_SH_DIR8WPL =            5;
+enum R_SH_DIR8WPZ =            6;
+enum R_SH_DIR8BP =             7;
+enum R_SH_DIR8W =              8;
+enum R_SH_DIR8L =              9;
+enum R_SH_SWITCH16 =           25;
+enum R_SH_SWITCH32 =           26;
+enum R_SH_USES =               27;
+enum R_SH_COUNT =              28;
+enum R_SH_ALIGN =              29;
+enum R_SH_CODE =               30;
+enum R_SH_DATA =               31;
+enum R_SH_LABEL =              32;
+enum R_SH_SWITCH8 =            33;
+enum R_SH_GNU_VTINHERIT =      34;
+enum R_SH_GNU_VTENTRY =        35;
+enum R_SH_TLS_GD_32 =          144;
+enum R_SH_TLS_LD_32 =          145;
+enum R_SH_TLS_LDO_32 =         146;
+enum R_SH_TLS_IE_32 =          147;
+enum R_SH_TLS_LE_32 =          148;
+enum R_SH_TLS_DTPMOD32 =       149;
+enum R_SH_TLS_DTPOFF32 =       150;
+enum R_SH_TLS_TPOFF32 =        151;
+enum R_SH_GOT32 =              160;
+enum R_SH_PLT32 =              161;
+enum R_SH_COPY =               162;
+enum R_SH_GLOB_DAT =           163;
+enum R_SH_JMP_SLOT =           164;
+enum R_SH_RELATIVE =           165;
+enum R_SH_GOTOFF =             166;
+enum R_SH_GOTPC =              167;
+enum R_SH_NUM =                256;
+
+enum EF_S390_HIGH_GPRS =    0x00000001;
+
+enum R_390_NONE =              0;
+enum R_390_8 =                 1;
+enum R_390_12 =                2;
+enum R_390_16 =                3;
+enum R_390_32 =                4;
+enum R_390_PC32 =              5;
+enum R_390_GOT12 =             6;
+enum R_390_GOT32 =             7;
+enum R_390_PLT32 =             8;
+enum R_390_COPY =              9;
+enum R_390_GLOB_DAT =          10;
+enum R_390_JMP_SLOT =          11;
+enum R_390_RELATIVE =          12;
+enum R_390_GOTOFF32 =          13;
+enum R_390_GOTPC =             14;
+enum R_390_GOT16 =             15;
+enum R_390_PC16 =              16;
+enum R_390_PC16DBL =           17;
+enum R_390_PLT16DBL =          18;
+enum R_390_PC32DBL =           19;
+enum R_390_PLT32DBL =          20;
+enum R_390_GOTPCDBL =          21;
+enum R_390_64 =                22;
+enum R_390_PC64 =              23;
+enum R_390_GOT64 =             24;
+enum R_390_PLT64 =             25;
+enum R_390_GOTENT =            26;
+enum R_390_GOTOFF16 =          27;
+enum R_390_GOTOFF64 =          28;
+enum R_390_GOTPLT12 =          29;
+enum R_390_GOTPLT16 =          30;
+enum R_390_GOTPLT32 =          31;
+enum R_390_GOTPLT64 =          32;
+enum R_390_GOTPLTENT =         33;
+enum R_390_PLTOFF16 =          34;
+enum R_390_PLTOFF32 =          35;
+enum R_390_PLTOFF64 =          36;
+enum R_390_TLS_LOAD =          37;
+enum R_390_TLS_GDCALL =        38;
+enum R_390_TLS_LDCALL =        39;
+enum R_390_TLS_GD32 =          40;
+enum R_390_TLS_GD64 =          41;
+enum R_390_TLS_GOTIE12 =       42;
+enum R_390_TLS_GOTIE32 =       43;
+enum R_390_TLS_GOTIE64 =       44;
+enum R_390_TLS_LDM32 =         45;
+enum R_390_TLS_LDM64 =         46;
+enum R_390_TLS_IE32 =          47;
+enum R_390_TLS_IE64 =          48;
+enum R_390_TLS_IEENT =         49;
+enum R_390_TLS_LE32 =          50;
+enum R_390_TLS_LE64 =          51;
+enum R_390_TLS_LDO32 =         52;
+enum R_390_TLS_LDO64 =         53;
+enum R_390_TLS_DTPMOD =        54;
+enum R_390_TLS_DTPOFF =        55;
+enum R_390_TLS_TPOFF =         56;
+enum R_390_20 =                57;
+enum R_390_GOT20 =             58;
+enum R_390_GOTPLT20 =          59;
+enum R_390_TLS_GOTIE20 =       60;
+enum R_390_IRELATIVE =         61;
+enum R_390_NUM =               62;
+enum R_CRIS_NONE =             0;
+enum R_CRIS_8 =                1;
+enum R_CRIS_16 =               2;
+enum R_CRIS_32 =               3;
+enum R_CRIS_8_PCREL =          4;
+enum R_CRIS_16_PCREL =         5;
+enum R_CRIS_32_PCREL =         6;
+enum R_CRIS_GNU_VTINHERIT =    7;
+enum R_CRIS_GNU_VTENTRY =      8;
+enum R_CRIS_COPY =             9;
+enum R_CRIS_GLOB_DAT =         10;
+enum R_CRIS_JUMP_SLOT =        11;
+enum R_CRIS_RELATIVE =         12;
+enum R_CRIS_16_GOT =           13;
+enum R_CRIS_32_GOT =           14;
+enum R_CRIS_16_GOTPLT =        15;
+enum R_CRIS_32_GOTPLT =        16;
+enum R_CRIS_32_GOTREL =        17;
+enum R_CRIS_32_PLT_GOTREL =    18;
+enum R_CRIS_32_PLT_PCREL =     19;
+
+enum R_CRIS_NUM =              20;
+enum R_X86_64_NONE =           0;
+enum R_X86_64_64 =             1;
+enum R_X86_64_PC32 =           2;
+enum R_X86_64_GOT32 =          3;
+enum R_X86_64_PLT32 =          4;
+enum R_X86_64_COPY =           5;
+enum R_X86_64_GLOB_DAT =       6;
+enum R_X86_64_JUMP_SLOT =      7;
+enum R_X86_64_RELATIVE =       8;
+enum R_X86_64_GOTPCREL =       9;
+enum R_X86_64_32 =             10;
+enum R_X86_64_32S =            11;
+enum R_X86_64_16 =             12;
+enum R_X86_64_PC16 =           13;
+enum R_X86_64_8 =              14;
+enum R_X86_64_PC8 =            15;
+enum R_X86_64_DTPMOD64 =       16;
+enum R_X86_64_DTPOFF64 =       17;
+enum R_X86_64_TPOFF64 =        18;
+enum R_X86_64_TLSGD =          19;
+enum R_X86_64_TLSLD =          20;
+enum R_X86_64_DTPOFF32 =       21;
+enum R_X86_64_GOTTPOFF =       22;
+enum R_X86_64_TPOFF32 =        23;
+enum R_X86_64_PC64 =           24;
+enum R_X86_64_GOTOFF64 =       25;
+enum R_X86_64_GOTPC32 =        26;
+enum R_X86_64_GOT64 =          27;
+enum R_X86_64_GOTPCREL64 =     28;
+enum R_X86_64_GOTPC64 =        29;
+enum R_X86_64_GOTPLT64 =       30;
+enum R_X86_64_PLTOFF64 =       31;
+enum R_X86_64_SIZE32 =         32;
+enum R_X86_64_SIZE64 =         33;
+enum R_X86_64_GOTPC32_TLSDESC = 34;
+enum R_X86_64_TLSDESC_CALL =   35;
+enum R_X86_64_TLSDESC =        36;
+enum R_X86_64_IRELATIVE =      37;
+enum R_X86_64_RELATIVE64 =     38;
+
+enum R_X86_64_NUM =            39;
+enum R_MN10300_NONE =          0;
+enum R_MN10300_32 =            1;
+enum R_MN10300_16 =            2;
+enum R_MN10300_8 =             3;
+enum R_MN10300_PCREL32 =       4;
+enum R_MN10300_PCREL16 =       5;
+enum R_MN10300_PCREL8 =        6;
+enum R_MN10300_GNU_VTINHERIT = 7;
+enum R_MN10300_GNU_VTENTRY =   8;
+enum R_MN10300_24 =            9;
+enum R_MN10300_GOTPC32 =       10;
+enum R_MN10300_GOTPC16 =       11;
+enum R_MN10300_GOTOFF32 =      12;
+enum R_MN10300_GOTOFF24 =      13;
+enum R_MN10300_GOTOFF16 =      14;
+enum R_MN10300_PLT32 =         15;
+enum R_MN10300_PLT16 =         16;
+enum R_MN10300_GOT32 =         17;
+enum R_MN10300_GOT24 =         18;
+enum R_MN10300_GOT16 =         19;
+enum R_MN10300_COPY =          20;
+enum R_MN10300_GLOB_DAT =      21;
+enum R_MN10300_JMP_SLOT =      22;
+enum R_MN10300_RELATIVE =      23;
+enum R_MN10300_TLS_GD =        24;
+enum R_MN10300_TLS_LD =        25;
+enum R_MN10300_TLS_LDO =       26;
+enum R_MN10300_TLS_GOTIE =     27;
+enum R_MN10300_TLS_IE =        28;
+enum R_MN10300_TLS_LE =        29;
+enum R_MN10300_TLS_DTPMOD =    30;
+enum R_MN10300_TLS_DTPOFF =    31;
+enum R_MN10300_TLS_TPOFF =     32;
+enum R_MN10300_SYM_DIFF =      33;
+enum R_MN10300_ALIGN =         34;
+enum R_MN10300_NUM =           35;
+enum R_M32R_NONE =             0;
+enum R_M32R_16 =               1;
+enum R_M32R_32 =               2;
+enum R_M32R_24 =               3;
+enum R_M32R_10_PCREL =         4;
+enum R_M32R_18_PCREL =         5;
+enum R_M32R_26_PCREL =         6;
+enum R_M32R_HI16_ULO =         7;
+enum R_M32R_HI16_SLO =         8;
+enum R_M32R_LO16 =             9;
+enum R_M32R_SDA16 =            10;
+enum R_M32R_GNU_VTINHERIT =    11;
+enum R_M32R_GNU_VTENTRY =      12;
+enum R_M32R_16_RELA =          33;
+enum R_M32R_32_RELA =          34;
+enum R_M32R_24_RELA =          35;
+enum R_M32R_10_PCREL_RELA =    36;
+enum R_M32R_18_PCREL_RELA =    37;
+enum R_M32R_26_PCREL_RELA =    38;
+enum R_M32R_HI16_ULO_RELA =    39;
+enum R_M32R_HI16_SLO_RELA =    40;
+enum R_M32R_LO16_RELA =        41;
+enum R_M32R_SDA16_RELA =       42;
+enum R_M32R_RELA_GNU_VTINHERIT =       43;
+enum R_M32R_RELA_GNU_VTENTRY = 44;
+enum R_M32R_REL32 =            45;
+
+enum R_M32R_GOT24 =            48;
+enum R_M32R_26_PLTREL =        49;
+enum R_M32R_COPY =             50;
+enum R_M32R_GLOB_DAT =         51;
+enum R_M32R_JMP_SLOT =         52;
+enum R_M32R_RELATIVE =         53;
+enum R_M32R_GOTOFF =           54;
+enum R_M32R_GOTPC24 =          55;
+enum R_M32R_GOT16_HI_ULO =     56;
+enum R_M32R_GOT16_HI_SLO =     57;
+enum R_M32R_GOT16_LO =         58;
+enum R_M32R_GOTPC_HI_ULO =     59;
+enum R_M32R_GOTPC_HI_SLO =     60;
+enum R_M32R_GOTPC_LO =         61;
+enum R_M32R_GOTOFF_HI_ULO =    62;
+enum R_M32R_GOTOFF_HI_SLO =    63;
+enum R_M32R_GOTOFF_LO =        64;
+enum R_M32R_NUM =              256;
+enum R_TILEPRO_NONE =          0;
+enum R_TILEPRO_32 =            1;
+enum R_TILEPRO_16 =            2;
+enum R_TILEPRO_8 =             3;
+enum R_TILEPRO_32_PCREL =      4;
+enum R_TILEPRO_16_PCREL =      5;
+enum R_TILEPRO_8_PCREL =       6;
+enum R_TILEPRO_LO16 =          7;
+enum R_TILEPRO_HI16 =          8;
+enum R_TILEPRO_HA16 =          9;
+enum R_TILEPRO_COPY =          10;
+enum R_TILEPRO_GLOB_DAT =      11;
+enum R_TILEPRO_JMP_SLOT =      12;
+enum R_TILEPRO_RELATIVE =      13;
+enum R_TILEPRO_BROFF_X1 =      14;
+enum R_TILEPRO_JOFFLONG_X1 =   15;
+enum R_TILEPRO_JOFFLONG_X1_PLT = 16;
+enum R_TILEPRO_IMM8_X0 =       17;
+enum R_TILEPRO_IMM8_Y0 =       18;
+enum R_TILEPRO_IMM8_X1 =       19;
+enum R_TILEPRO_IMM8_Y1 =       20;
+enum R_TILEPRO_MT_IMM15_X1 =   21;
+enum R_TILEPRO_MF_IMM15_X1 =   22;
+enum R_TILEPRO_IMM16_X0 =      23;
+enum R_TILEPRO_IMM16_X1 =      24;
+enum R_TILEPRO_IMM16_X0_LO =   25;
+enum R_TILEPRO_IMM16_X1_LO =   26;
+enum R_TILEPRO_IMM16_X0_HI =   27;
+enum R_TILEPRO_IMM16_X1_HI =   28;
+enum R_TILEPRO_IMM16_X0_HA =   29;
+enum R_TILEPRO_IMM16_X1_HA =   30;
+enum R_TILEPRO_IMM16_X0_PCREL = 31;
+enum R_TILEPRO_IMM16_X1_PCREL = 32;
+enum R_TILEPRO_IMM16_X0_LO_PCREL = 33;
+enum R_TILEPRO_IMM16_X1_LO_PCREL = 34;
+enum R_TILEPRO_IMM16_X0_HI_PCREL = 35;
+enum R_TILEPRO_IMM16_X1_HI_PCREL = 36;
+enum R_TILEPRO_IMM16_X0_HA_PCREL = 37;
+enum R_TILEPRO_IMM16_X1_HA_PCREL = 38;
+enum R_TILEPRO_IMM16_X0_GOT =  39;
+enum R_TILEPRO_IMM16_X1_GOT =  40;
+enum R_TILEPRO_IMM16_X0_GOT_LO = 41;
+enum R_TILEPRO_IMM16_X1_GOT_LO = 42;
+enum R_TILEPRO_IMM16_X0_GOT_HI = 43;
+enum R_TILEPRO_IMM16_X1_GOT_HI = 44;
+enum R_TILEPRO_IMM16_X0_GOT_HA = 45;
+enum R_TILEPRO_IMM16_X1_GOT_HA = 46;
+enum R_TILEPRO_MMSTART_X0 =    47;
+enum R_TILEPRO_MMEND_X0 =      48;
+enum R_TILEPRO_MMSTART_X1 =    49;
+enum R_TILEPRO_MMEND_X1 =      50;
+enum R_TILEPRO_SHAMT_X0 =      51;
+enum R_TILEPRO_SHAMT_X1 =      52;
+enum R_TILEPRO_SHAMT_Y0 =      53;
+enum R_TILEPRO_SHAMT_Y1 =      54;
+enum R_TILEPRO_DEST_IMM8_X1 =  55;
+enum R_TILEPRO_TLS_GD_CALL =   60;
+enum R_TILEPRO_IMM8_X0_TLS_GD_ADD = 61;
+enum R_TILEPRO_IMM8_X1_TLS_GD_ADD = 62;
+enum R_TILEPRO_IMM8_Y0_TLS_GD_ADD = 63;
+enum R_TILEPRO_IMM8_Y1_TLS_GD_ADD = 64;
+enum R_TILEPRO_TLS_IE_LOAD =   65;
+enum R_TILEPRO_IMM16_X0_TLS_GD = 66;
+enum R_TILEPRO_IMM16_X1_TLS_GD = 67;
+enum R_TILEPRO_IMM16_X0_TLS_GD_LO = 68;
+enum R_TILEPRO_IMM16_X1_TLS_GD_LO = 69;
+enum R_TILEPRO_IMM16_X0_TLS_GD_HI = 70;
+enum R_TILEPRO_IMM16_X1_TLS_GD_HI = 71;
+enum R_TILEPRO_IMM16_X0_TLS_GD_HA = 72;
+enum R_TILEPRO_IMM16_X1_TLS_GD_HA = 73;
+enum R_TILEPRO_IMM16_X0_TLS_IE = 74;
+enum R_TILEPRO_IMM16_X1_TLS_IE = 75;
+enum R_TILEPRO_IMM16_X0_TLS_IE_LO = 76;
+enum R_TILEPRO_IMM16_X1_TLS_IE_LO = 77;
+enum R_TILEPRO_IMM16_X0_TLS_IE_HI = 78;
+enum R_TILEPRO_IMM16_X1_TLS_IE_HI = 79;
+enum R_TILEPRO_IMM16_X0_TLS_IE_HA = 80;
+enum R_TILEPRO_IMM16_X1_TLS_IE_HA = 81;
+enum R_TILEPRO_TLS_DTPMOD32 =  82;
+enum R_TILEPRO_TLS_DTPOFF32 =  83;
+enum R_TILEPRO_TLS_TPOFF32 =   84;
+enum R_TILEPRO_IMM16_X0_TLS_LE = 85;
+enum R_TILEPRO_IMM16_X1_TLS_LE = 86;
+enum R_TILEPRO_IMM16_X0_TLS_LE_LO = 87;
+enum R_TILEPRO_IMM16_X1_TLS_LE_LO = 88;
+enum R_TILEPRO_IMM16_X0_TLS_LE_HI = 89;
+enum R_TILEPRO_IMM16_X1_TLS_LE_HI = 90;
+enum R_TILEPRO_IMM16_X0_TLS_LE_HA = 91;
+enum R_TILEPRO_IMM16_X1_TLS_LE_HA = 92;
+
+enum R_TILEPRO_GNU_VTINHERIT = 128;
+enum R_TILEPRO_GNU_VTENTRY =   129;
+
+enum R_TILEPRO_NUM =           130;
+enum R_TILEGX_NONE =           0;
+enum R_TILEGX_64 =             1;
+enum R_TILEGX_32 =             2;
+enum R_TILEGX_16 =             3;
+enum R_TILEGX_8 =              4;
+enum R_TILEGX_64_PCREL =       5;
+enum R_TILEGX_32_PCREL =       6;
+enum R_TILEGX_16_PCREL =       7;
+enum R_TILEGX_8_PCREL =        8;
+enum R_TILEGX_HW0 =            9;
+enum R_TILEGX_HW1 =            10;
+enum R_TILEGX_HW2 =            11;
+enum R_TILEGX_HW3 =            12;
+enum R_TILEGX_HW0_LAST =       13;
+enum R_TILEGX_HW1_LAST =       14;
+enum R_TILEGX_HW2_LAST =       15;
+enum R_TILEGX_COPY =           16;
+enum R_TILEGX_GLOB_DAT =       17;
+enum R_TILEGX_JMP_SLOT =       18;
+enum R_TILEGX_RELATIVE =       19;
+enum R_TILEGX_BROFF_X1 =       20;
+enum R_TILEGX_JUMPOFF_X1 =     21;
+enum R_TILEGX_JUMPOFF_X1_PLT = 22;
+enum R_TILEGX_IMM8_X0 =        23;
+enum R_TILEGX_IMM8_Y0 =        24;
+enum R_TILEGX_IMM8_X1 =        25;
+enum R_TILEGX_IMM8_Y1 =        26;
+enum R_TILEGX_DEST_IMM8_X1 =   27;
+enum R_TILEGX_MT_IMM14_X1 =    28;
+enum R_TILEGX_MF_IMM14_X1 =    29;
+enum R_TILEGX_MMSTART_X0 =     30;
+enum R_TILEGX_MMEND_X0 =       31;
+enum R_TILEGX_SHAMT_X0 =       32;
+enum R_TILEGX_SHAMT_X1 =       33;
+enum R_TILEGX_SHAMT_Y0 =       34;
+enum R_TILEGX_SHAMT_Y1 =       35;
+enum R_TILEGX_IMM16_X0_HW0 =   36;
+enum R_TILEGX_IMM16_X1_HW0 =   37;
+enum R_TILEGX_IMM16_X0_HW1 =   38;
+enum R_TILEGX_IMM16_X1_HW1 =   39;
+enum R_TILEGX_IMM16_X0_HW2 =   40;
+enum R_TILEGX_IMM16_X1_HW2 =   41;
+enum R_TILEGX_IMM16_X0_HW3 =   42;
+enum R_TILEGX_IMM16_X1_HW3 =   43;
+enum R_TILEGX_IMM16_X0_HW0_LAST = 44;
+enum R_TILEGX_IMM16_X1_HW0_LAST = 45;
+enum R_TILEGX_IMM16_X0_HW1_LAST = 46;
+enum R_TILEGX_IMM16_X1_HW1_LAST = 47;
+enum R_TILEGX_IMM16_X0_HW2_LAST = 48;
+enum R_TILEGX_IMM16_X1_HW2_LAST = 49;
+enum R_TILEGX_IMM16_X0_HW0_PCREL = 50;
+enum R_TILEGX_IMM16_X1_HW0_PCREL = 51;
+enum R_TILEGX_IMM16_X0_HW1_PCREL = 52;
+enum R_TILEGX_IMM16_X1_HW1_PCREL = 53;
+enum R_TILEGX_IMM16_X0_HW2_PCREL = 54;
+enum R_TILEGX_IMM16_X1_HW2_PCREL = 55;
+enum R_TILEGX_IMM16_X0_HW3_PCREL = 56;
+enum R_TILEGX_IMM16_X1_HW3_PCREL = 57;
+enum R_TILEGX_IMM16_X0_HW0_LAST_PCREL = 58;
+enum R_TILEGX_IMM16_X1_HW0_LAST_PCREL = 59;
+enum R_TILEGX_IMM16_X0_HW1_LAST_PCREL = 60;
+enum R_TILEGX_IMM16_X1_HW1_LAST_PCREL = 61;
+enum R_TILEGX_IMM16_X0_HW2_LAST_PCREL = 62;
+enum R_TILEGX_IMM16_X1_HW2_LAST_PCREL = 63;
+enum R_TILEGX_IMM16_X0_HW0_GOT = 64;
+enum R_TILEGX_IMM16_X1_HW0_GOT = 65;
+enum R_TILEGX_IMM16_X0_HW0_PLT_PCREL = 66;
+enum R_TILEGX_IMM16_X1_HW0_PLT_PCREL = 67;
+enum R_TILEGX_IMM16_X0_HW1_PLT_PCREL = 68;
+enum R_TILEGX_IMM16_X1_HW1_PLT_PCREL = 69;
+enum R_TILEGX_IMM16_X0_HW2_PLT_PCREL = 70;
+enum R_TILEGX_IMM16_X1_HW2_PLT_PCREL = 71;
+enum R_TILEGX_IMM16_X0_HW0_LAST_GOT = 72;
+enum R_TILEGX_IMM16_X1_HW0_LAST_GOT = 73;
+enum R_TILEGX_IMM16_X0_HW1_LAST_GOT = 74;
+enum R_TILEGX_IMM16_X1_HW1_LAST_GOT = 75;
+enum R_TILEGX_IMM16_X0_HW3_PLT_PCREL = 76;
+enum R_TILEGX_IMM16_X1_HW3_PLT_PCREL = 77;
+enum R_TILEGX_IMM16_X0_HW0_TLS_GD = 78;
+enum R_TILEGX_IMM16_X1_HW0_TLS_GD = 79;
+enum R_TILEGX_IMM16_X0_HW0_TLS_LE = 80;
+enum R_TILEGX_IMM16_X1_HW0_TLS_LE = 81;
+enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE = 82;
+enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE = 83;
+enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE = 84;
+enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE = 85;
+enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD = 86;
+enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD = 87;
+enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD = 88;
+enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD = 89;
+enum R_TILEGX_IMM16_X0_HW0_TLS_IE = 92;
+enum R_TILEGX_IMM16_X1_HW0_TLS_IE = 93;
+enum R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL = 94;
+enum R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL = 95;
+enum R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL = 96;
+enum R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL = 97;
+enum R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL = 98;
+enum R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL = 99;
+enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE = 100;
+enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE = 101;
+enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE = 102;
+enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE = 103;
+enum R_TILEGX_TLS_DTPMOD64 =   106;
+enum R_TILEGX_TLS_DTPOFF64 =   107;
+enum R_TILEGX_TLS_TPOFF64 =    108;
+enum R_TILEGX_TLS_DTPMOD32 =   109;
+enum R_TILEGX_TLS_DTPOFF32 =   110;
+enum R_TILEGX_TLS_TPOFF32 =    111;
+enum R_TILEGX_TLS_GD_CALL =    112;
+enum R_TILEGX_IMM8_X0_TLS_GD_ADD = 113;
+enum R_TILEGX_IMM8_X1_TLS_GD_ADD = 114;
+enum R_TILEGX_IMM8_Y0_TLS_GD_ADD = 115;
+enum R_TILEGX_IMM8_Y1_TLS_GD_ADD = 116;
+enum R_TILEGX_TLS_IE_LOAD =    117;
+enum R_TILEGX_IMM8_X0_TLS_ADD = 118;
+enum R_TILEGX_IMM8_X1_TLS_ADD = 119;
+enum R_TILEGX_IMM8_Y0_TLS_ADD = 120;
+enum R_TILEGX_IMM8_Y1_TLS_ADD = 121;
+
+enum R_TILEGX_GNU_VTINHERIT =  128;
+enum R_TILEGX_GNU_VTENTRY =    129;
+
+enum R_TILEGX_NUM =            130;
index 63cc4f9328a6bf63ecb943823de72950fb692f10..134cdf0650fc2f42abcd7f98f581adf891b94911 100644 (file)
@@ -13,108 +13,13 @@ nothrow:
 import core.stdc.stdint;
 public import core.sys.freebsd.sys.elf_common;
 
-alias uint16_t Elf32_Half;
-alias uint32_t Elf32_Word;
-alias int32_t  Elf32_Sword;
 alias uint64_t Elf32_Lword;
-alias uint32_t Elf32_Addr;
-alias uint32_t Elf32_Off;
 alias Elf32_Word Elf32_Hashelt;
 alias Elf32_Word Elf32_Size;
 alias Elf32_Sword Elf32_Ssize;
 
-struct Elf32_Ehdr
-{
-    char[EI_NIDENT] e_ident = 0;
-    Elf32_Half    e_type;
-    Elf32_Half    e_machine;
-    Elf32_Word    e_version;
-    Elf32_Addr    e_entry;
-    Elf32_Off     e_phoff;
-    Elf32_Off     e_shoff;
-    Elf32_Word    e_flags;
-    Elf32_Half    e_ehsize;
-    Elf32_Half    e_phentsize;
-    Elf32_Half    e_phnum;
-    Elf32_Half    e_shentsize;
-    Elf32_Half    e_shnum;
-    Elf32_Half    e_shstrndx;
-}
-
-struct Elf32_Shdr
-{
-    Elf32_Word    sh_name;
-    Elf32_Word    sh_type;
-    Elf32_Word    sh_flags;
-    Elf32_Addr    sh_addr;
-    Elf32_Off     sh_offset;
-    Elf32_Word    sh_size;
-    Elf32_Word    sh_link;
-    Elf32_Word    sh_info;
-    Elf32_Word    sh_addralign;
-    Elf32_Word    sh_entsize;
-}
-
-struct Elf32_Phdr
-{
-    Elf32_Word    p_type;
-    Elf32_Off     p_offset;
-    Elf32_Addr    p_vaddr;
-    Elf32_Addr    p_paddr;
-    Elf32_Word    p_filesz;
-    Elf32_Word    p_memsz;
-    Elf32_Word    p_flags;
-    Elf32_Word    p_align;
-}
-
-struct Elf32_Dyn
-{
-  Elf32_Sword   d_tag;
-  union _d_un
-  {
-      Elf32_Word d_val;
-      Elf32_Addr d_ptr;
-  } _d_un d_un;
-}
-
-struct Elf32_Rel
-{
-    Elf32_Addr    r_offset;
-    Elf32_Word    r_info;
-}
-
-struct Elf32_Rela
-{
-    Elf32_Addr    r_offset;
-    Elf32_Word    r_info;
-    Elf32_Sword   r_addend;
-}
-
-extern (D)
-{
-    auto ELF32_R_SYM(V)(V val) { return val >> 8; }
-    auto ELF32_R_TYPE(V)(V val) { return val & 0xff; }
-    auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); }
-}
-
 alias Elf_Note Elf32_Nhdr;
 
-struct Elf32_Move
-{
-    Elf32_Lword   m_value;
-    Elf32_Word    m_info;
-    Elf32_Word    m_poffset;
-    Elf32_Half    m_repeat;
-    Elf32_Half    m_stride;
-}
-
-extern (D)
-{
-    auto ELF32_M_SYM(I)(I info) { return info >> 8; }
-    auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; }
-    auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; }
-}
-
 struct Elf32_Cap
 {
     Elf32_Word    c_tag;
@@ -125,63 +30,7 @@ struct Elf32_Cap
     } _c_un c_un;
 }
 
-struct Elf32_Sym
-{
-    Elf32_Word    st_name;
-    Elf32_Addr    st_value;
-    Elf32_Word    st_size;
-    ubyte st_info;
-    ubyte st_other;
-    Elf32_Half st_shndx;
-}
-
 extern (D)
 {
-    auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
-    auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; }
-    auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); }
     auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; }
 }
-
-struct Elf32_Verdef
-{
-    Elf32_Half    vd_version;
-    Elf32_Half    vd_flags;
-    Elf32_Half    vd_ndx;
-    Elf32_Half    vd_cnt;
-    Elf32_Word    vd_hash;
-    Elf32_Word    vd_aux;
-    Elf32_Word    vd_next;
-}
-
-struct Elf32_Verdaux
-{
-    Elf32_Word    vda_name;
-    Elf32_Word    vda_next;
-}
-
-struct Elf32_Verneed
-{
-    Elf32_Half    vn_version;
-    Elf32_Half    vn_cnt;
-    Elf32_Word    vn_file;
-    Elf32_Word    vn_aux;
-    Elf32_Word    vn_next;
-}
-
-struct Elf32_Vernaux
-{
-    Elf32_Word    vna_hash;
-    Elf32_Half    vna_flags;
-    Elf32_Half    vna_other;
-    Elf32_Word    vna_name;
-    Elf32_Word    vna_next;
-}
-
-alias Elf32_Half Elf32_Versym;
-
-struct Elf32_Syminfo
-{
-    Elf32_Half si_boundto;
-    Elf32_Half si_flags;
-}
index 8c63e04973d58e8cfc4c5d3c819473947c9ae1f3..69528217941e555ebae03c02a1d9062940262177 100644 (file)
@@ -13,100 +13,13 @@ nothrow:
 import core.stdc.stdint;
 public import core.sys.freebsd.sys.elf_common;
 
-alias uint16_t Elf64_Half;
-alias uint32_t Elf64_Word;
-alias int32_t  Elf64_Sword;
 alias uint64_t Elf64_Lword;
-alias uint64_t Elf64_Xword;
-alias int64_t  Elf64_Sxword;
-alias uint64_t Elf64_Addr;
-alias uint64_t Elf64_Off;
 alias Elf64_Word Elf64_Hashelt;
 alias Elf64_Xword Elf64_Size;
 alias Elf64_Sxword Elf64_Ssize;
 
-struct Elf64_Ehdr
-{
-    char[EI_NIDENT] e_ident = 0;
-    Elf64_Half    e_type;
-    Elf64_Half    e_machine;
-    Elf64_Word    e_version;
-    Elf64_Addr    e_entry;
-    Elf64_Off     e_phoff;
-    Elf64_Off     e_shoff;
-    Elf64_Word    e_flags;
-    Elf64_Half    e_ehsize;
-    Elf64_Half    e_phentsize;
-    Elf64_Half    e_phnum;
-    Elf64_Half    e_shentsize;
-    Elf64_Half    e_shnum;
-    Elf64_Half    e_shstrndx;
-}
-
-struct Elf64_Lib
-{
-    Elf64_Word    l_name;
-    Elf64_Word    l_time_stamp;
-    Elf64_Word    l_checksum;
-    Elf64_Word    l_version;
-    Elf64_Word    l_flags;
-}
-
-struct Elf64_Shdr
-{
-    Elf64_Word    sh_name;
-    Elf64_Word    sh_type;
-    Elf64_Xword   sh_flags;
-    Elf64_Addr    sh_addr;
-    Elf64_Off     sh_offset;
-    Elf64_Xword   sh_size;
-    Elf64_Word    sh_link;
-    Elf64_Word    sh_info;
-    Elf64_Xword   sh_addralign;
-    Elf64_Xword   sh_entsize;
-}
-
-struct Elf64_Phdr
-{
-    Elf64_Word    p_type;
-    Elf64_Word    p_flags;
-    Elf64_Off     p_offset;
-    Elf64_Addr    p_vaddr;
-    Elf64_Addr    p_paddr;
-    Elf64_Xword   p_filesz;
-    Elf64_Xword   p_memsz;
-    Elf64_Xword   p_align;
-}
-
-struct Elf64_Dyn
-{
-  Elf64_Sxword  d_tag;
-  union _d_un
-  {
-      Elf64_Xword d_val;
-      Elf64_Addr d_ptr;
-  } _d_un d_un;
-}
-
-struct Elf64_Rel
-{
-    Elf64_Addr    r_offset;
-    Elf64_Xword   r_info;
-}
-
-struct Elf64_Rela
-{
-    Elf64_Addr    r_offset;
-    Elf64_Xword   r_info;
-    Elf64_Sxword  r_addend;
-}
-
 extern (D)
 {
-    auto ELF64_R_SYM(I)(I i) { return i >> 32; }
-    auto ELF64_R_TYPE(I)(I i) { return i & 0xffffffff; }
-    auto ELF64_R_INFO(S, T)(S sym, T type) { return (sym << 32) + (type & 0xffffffff); }
-
     auto ELF64_R_TYPE_DATA(I)(I i) { return (cast(Elf64_Xword) i << 32) >> 40; }
     auto ELF64_R_TYPE_ID(I)(I i) { return (cast(Elf64_Xword) i << 56 ) >> 56; }
     auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; }
@@ -114,22 +27,6 @@ extern (D)
 
 alias Elf_Note Elf64_Nhdr;
 
-struct Elf64_Move
-{
-    Elf64_Lword   m_value;
-    Elf64_Xword   m_info;
-    Elf64_Xword   m_poffset;
-    Elf64_Half    m_repeat;
-    Elf64_Half    m_stride;
-}
-
-extern (D)
-{
-    auto ELF64_M_SYM(I)(I info) { return info >> 8; }
-    auto ELF64_M_SIZE(I)(I info) { return cast(ubyte)info; }
-    auto ELF64_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; }
-}
-
 struct Elf64_Cap
 {
     Elf64_Xword   c_tag;
@@ -140,63 +37,7 @@ struct Elf64_Cap
     } _c_un c_un;
 }
 
-struct Elf64_Sym
-{
-    Elf64_Word    st_name;
-    ubyte st_info;
-    ubyte st_other;
-    Elf64_Half st_shndx;
-    Elf64_Addr    st_value;
-    Elf64_Xword   st_size;
-}
-
 extern (D)
 {
-    auto ELF64_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
-    auto ELF64_ST_TYPE(T)(T val) { return val & 0xf; }
-    auto ELF64_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); }
     auto ELF64_ST_VISIBILITY(O)(O o) { return o & 0x03; }
 }
-
-struct Elf64_Verdef
-{
-    Elf64_Half    vd_version;
-    Elf64_Half    vd_flags;
-    Elf64_Half    vd_ndx;
-    Elf64_Half    vd_cnt;
-    Elf64_Word    vd_hash;
-    Elf64_Word    vd_aux;
-    Elf64_Word    vd_next;
-}
-
-struct Elf64_Verdaux
-{
-    Elf64_Word    vda_name;
-    Elf64_Word    vda_next;
-}
-
-struct Elf64_Verneed
-{
-    Elf64_Half    vn_version;
-    Elf64_Half    vn_cnt;
-    Elf64_Word    vn_file;
-    Elf64_Word    vn_aux;
-    Elf64_Word    vn_next;
-}
-
-struct Elf64_Vernaux
-{
-    Elf64_Word    vna_hash;
-    Elf64_Half    vna_flags;
-    Elf64_Half    vna_other;
-    Elf64_Word    vna_name;
-    Elf64_Word    vna_next;
-}
-
-alias Elf64_Half Elf64_Versym;
-
-struct Elf64_Syminfo
-{
-    Elf64_Half si_boundto;
-    Elf64_Half si_flags;
-}
index 455de95afb3e9feae300ebaddccd19a1dcf1510f..05e78bf0dc6caf6c3280a7964a2bb5a3da184c86 100644 (file)
@@ -11,6 +11,7 @@ pure:
 nothrow:
 
 import core.stdc.stdint;
+public import core.sys.elf;
 
 struct Elf_Note
 {
@@ -27,57 +28,7 @@ struct Elf_GNU_Hash_Header
     uint32_t      gh_shift2;
 }
 
-enum EI_MAG0 =         0;
-enum EI_MAG1 =         1;
-enum EI_MAG2 =         2;
-enum EI_MAG3 =         3;
-enum EI_CLASS =        4;
-enum EI_DATA =         5;
-enum EI_VERSION =      6;
-enum EI_OSABI =        7;
-enum EI_ABIVERSION =   8;
 enum OLD_EI_BRAND =    8;
-enum EI_PAD =          9;
-enum EI_NIDENT =       16;
-
-enum ELFMAG0 =         0x7f;
-enum ELFMAG1 =         'E';
-enum ELFMAG2 =         'L';
-enum ELFMAG3 =         'F';
-enum ELFMAG =          "\177ELF";
-enum SELFMAG =         4;
-
-enum EV_NONE =         0;
-enum EV_CURRENT =      1;
-
-enum ELFCLASSNONE =    0;
-enum ELFCLASS32 =      1;
-enum ELFCLASS64 =      2;
-
-enum ELFDATANONE =     0;
-enum ELFDATA2LSB =     1;
-enum ELFDATA2MSB =     2;
-
-enum ELFOSABI_NONE =           0;
-enum ELFOSABI_SYSV =           0;
-enum ELFOSABI_HPUX =           1;
-enum ELFOSABI_NETBSD =         2;
-enum ELFOSABI_LINUX =          3;
-enum ELFOSABI_HURD  =          4;
-enum ELFOSABI_86OPEN =         5;
-enum ELFOSABI_SOLARIS =        6;
-enum ELFOSABI_AIX =            7;
-enum ELFOSABI_MONTEREY =       7;
-enum ELFOSABI_IRIX =           8;
-enum ELFOSABI_FREEBSD =        9;
-enum ELFOSABI_TRU64 =          10;
-enum ELFOSABI_MODESTO =        11;
-enum ELFOSABI_OPENBSD =        12;
-enum ELFOSABI_OPENVMS =        13;
-enum ELFOSABI_NSK =            14;
-enum ELFOSABI_AROS =           15;
-enum ELFOSABI_ARM =            97;
-enum ELFOSABI_STANDALONE =     255;
 
 extern (D)
 {
@@ -87,306 +38,28 @@ extern (D)
                                     ehdr.e_ident[EI_MAG3] == ELFMAG3; }
 }
 
-enum ET_NONE =         0;
-enum ET_REL =          1;
-enum ET_EXEC =         2;
-enum ET_DYN =          3;
-enum ET_CORE =         4;
-enum ET_LOOS =         0xfe00;
-enum ET_HIOS =         0xfeff;
-enum ET_LOPROC =       0xff00;
-enum ET_HIPROC =       0xffff;
-
-enum EM_NONE =          0;
-enum EM_M32 =           1;
-enum EM_SPARC =         2;
-enum EM_386 =           3;
-enum EM_68K =           4;
-enum EM_88K =           5;
-enum EM_860 =           7;
-enum EM_MIPS =          8;
-enum EM_S370 =          9;
-enum EM_MIPS_RS3_LE =  10;
-enum EM_PARISC =       15;
-enum EM_VPP500 =       17;
-enum EM_SPARC32PLUS =  18;
-enum EM_960 =          19;
-enum EM_PPC =          20;
-enum EM_PPC64 =        21;
-enum EM_S390 =         22;
-enum EM_V800 =         36;
-enum EM_FR20 =         37;
-enum EM_RH32 =         38;
-enum EM_RCE =          39;
-enum EM_ARM =          40;
-enum EM_SH =           42;
-enum EM_SPARCV9 =      43;
-enum EM_TRICORE =      44;
-enum EM_ARC =          45;
-enum EM_H8_300 =       46;
-enum EM_H8_300H =      47;
-enum EM_H8S =          48;
-enum EM_H8_500 =       49;
-enum EM_IA_64 =        50;
-enum EM_MIPS_X =       51;
-enum EM_COLDFIRE =     52;
-enum EM_68HC12 =       53;
-enum EM_MMA =          54;
-enum EM_PCP =          55;
-enum EM_NCPU =         56;
-enum EM_NDR1 =         57;
-enum EM_STARCORE =     58;
-enum EM_ME16 =         59;
-enum EM_ST100 =        60;
-enum EM_TINYJ =        61;
-enum EM_X86_64 =       62;
-enum EM_AMD64 =        62;
-enum EM_PDSP =         63;
-enum EM_FX66 =         66;
-enum EM_ST9PLUS =      67;
-enum EM_ST7 =          68;
-enum EM_68HC16 =       69;
-enum EM_68HC11 =       70;
-enum EM_68HC08 =       71;
-enum EM_68HC05 =       72;
-enum EM_SVX =          73;
-enum EM_ST19 =         74;
-enum EM_VAX =          75;
-enum EM_CRIS =         76;
-enum EM_JAVELIN =      77;
-enum EM_FIREPATH =     78;
-enum EM_ZSP =          79;
-enum EM_MMIX =         80;
-enum EM_HUANY =        81;
-enum EM_PRISM =        82;
-enum EM_AVR =          83;
-enum EM_FR30 =         84;
-enum EM_D10V =         85;
-enum EM_D30V =         86;
-enum EM_V850 =         87;
-enum EM_M32R =         88;
-enum EM_MN10300 =      89;
-enum EM_MN10200 =      90;
-enum EM_PJ =           91;
-enum EM_OPENRISC =     92;
-enum EM_ARC_A5 =       93;
-enum EM_XTENSA =       94;
-enum EM_VIDEOCORE =    95;
-enum EM_TMM_GPP =      96;
-enum EM_NS32K =        97;
-enum EM_TPC =          98;
-enum EM_SNP1K =        99;
-enum EM_ST200 =       100;
-enum EM_IP2K =        101;
-enum EM_MAX =         102;
-enum EM_CR =          103;
-enum EM_F2MC16 =      104;
-enum EM_MSP430 =      105;
-enum EM_BLACKFIN =    106;
-enum EM_SE_C33 =      107;
-enum EM_SEP =         108;
-enum EM_ARCA =        109;
-enum EM_UNICORE =     110;
-
 enum EM_486 =           6;
 enum EM_MIPS_RS4_BE =  10;
 enum EM_ALPHA_STD =    41;
-enum EM_ALPHA =    0x9026;
-
-enum SHN_UNDEF =       0;
-enum SHN_LORESERVE =   0xff00;
-enum SHN_LOPROC =      0xff00;
-enum SHN_HIPROC =      0xff1f;
-enum SHN_LOOS =        0xff20;
-enum SHN_HIOS =        0xff3f;
-enum SHN_ABS =         0xfff1;
-enum SHN_COMMON =      0xfff2;
-enum SHN_XINDEX =      0xffff;
-enum SHN_HIRESERVE =   0xffff;
-
-enum SHT_NULL =          0;
-enum SHT_PROGBITS =      1;
-enum SHT_SYMTAB =        2;
-enum SHT_STRTAB =        3;
-enum SHT_RELA =          4;
-enum SHT_HASH =          5;
-enum SHT_DYNAMIC =       6;
-enum SHT_NOTE =          7;
-enum SHT_NOBITS =        8;
-enum SHT_REL =           9;
-enum SHT_SHLIB =         10;
-enum SHT_DYNSYM =        11;
-enum SHT_INIT_ARRAY =    14;
-enum SHT_FINI_ARRAY =    15;
-enum SHT_PREINIT_ARRAY = 16;
-enum SHT_GROUP =         17;
-enum SHT_SYMTAB_SHNDX =  18;
-enum SHT_LOOS =          0x60000000;
-enum SHT_LOSUNW =        0x6ffffff4;
 enum SHT_SUNW_dof =      0x6ffffff4;
 enum SHT_SUNW_cap =      0x6ffffff5;
 enum SHT_SUNW_SIGNATURE = 0x6ffffff6;
-enum SHT_GNU_HASH =      0x6ffffff6;
-enum SHT_SUNW_ANNOTATE = 0x6ffffff7;
-enum SHT_SUNW_DEBUGSTR = 0x6ffffff8;
-enum SHT_SUNW_DEBUG =    0x6ffffff9;
-enum SHT_SUNW_move =     0x6ffffffa;
-enum SHT_SUNW_COMDAT =   0x6ffffffb;
-enum SHT_SUNW_syminfo =  0x6ffffffc;
 enum SHT_SUNW_verdef =   0x6ffffffd;
-enum SHT_GNU_verdef =    0x6ffffffd;
 enum SHT_SUNW_verneed =  0x6ffffffe;
-enum SHT_GNU_verneed =   0x6ffffffe;
 enum SHT_SUNW_versym =   0x6fffffff;
-enum SHT_GNU_versym =    0x6fffffff;
-enum SHT_HISUNW =        0x6fffffff;
-enum SHT_HIOS =          0x6fffffff;
-enum SHT_LOPROC =        0x70000000;
-enum SHT_AMD64_UNWIND =  0x70000001;
-enum SHT_ARM_EXIDX =     0x70000001;
-enum SHT_ARM_PREEMPTMAP = 0x70000002;
-enum SHT_ARM_ATTRIBUTES = 0x70000003;
-enum SHT_ARM_DEBUGOVERLAY = 0x70000004;
-enum SHT_ARM_OVERLAYSECTION = 0x70000005;
-enum SHT_MIPS_REGINFO =  0x70000006;
-enum SHT_MIPS_OPTIONS =  0x7000000d;
-enum SHT_MIPS_DWARF =    0x7000001e;
-enum SHT_HIPROC =        0x7fffffff;
-enum SHT_LOUSER =        0x80000000;
-enum SHT_HIUSER =        0x8fffffff;
 
-enum SHF_WRITE =            (1 << 0);
-enum SHF_ALLOC =            (1 << 1);
-enum SHF_EXECINSTR =        (1 << 2);
-enum SHF_MERGE =            (1 << 4);
-enum SHF_STRINGS =          (1 << 5);
-enum SHF_INFO_LINK =        (1 << 6);
-enum SHF_LINK_ORDER =       (1 << 7);
-enum SHF_OS_NONCONFORMING = (1 << 8);
-enum SHF_GROUP =            (1 << 9);
-enum SHF_TLS =              (1 << 10);
-enum SHF_COMPRESSED =       (1 << 11);
-enum SHF_MASKOS =           0x0ff00000;
-enum SHF_MASKPROC =         0xf0000000;
-
-enum PT_NULL =         0;
-enum PT_LOAD =         1;
-enum PT_DYNAMIC =      2;
-enum PT_INTERP =       3;
-enum PT_NOTE =         4;
-enum PT_SHLIB =        5;
-enum PT_PHDR =         6;
-enum PT_TLS =          7;
-enum PT_LOOS =         0x60000000;
-enum PT_SUNW_UNWIND =  0x6464e550;
-enum PT_GNU_EH_FRAME = 0x6474e550;
-enum PT_GNU_STACK =    0x6474e551;
-enum PT_GNU_RELRO =    0x6474e552;
-enum PT_LOSUNW =       0x6ffffffa;
-enum PT_SUNWBSS =      0x6ffffffa;
-enum PT_SUNWSTACK =    0x6ffffffb;
 enum PT_SUNWDTRACE =   0x6ffffffc;
 enum PT_SUNWCAP =      0x6ffffffd;
-enum PT_HISUNW =       0x6fffffff;
-enum PT_HIOS =         0x6fffffff;
-enum PT_LOPROC =       0x70000000;
-enum PT_HIPROC =       0x7fffffff;
-
-enum PF_X =            (1 << 0);
-enum PF_W =            (1 << 1);
-enum PF_R =            (1 << 2);
-enum PF_MASKOS =       0x0ff00000;
-enum PF_MASKPROC =     0xf0000000;
 
-enum PN_XNUM =         0xffff;
-
-enum DT_NULL =         0;
-enum DT_NEEDED =       1;
-enum DT_PLTRELSZ =     2;
-enum DT_PLTGOT =       3;
-enum DT_HASH =         4;
-enum DT_STRTAB =       5;
-enum DT_SYMTAB =       6;
-enum DT_RELA =         7;
-enum DT_RELASZ =       8;
-enum DT_RELAENT =      9;
-enum DT_STRSZ =        10;
-enum DT_SYMENT =       11;
-enum DT_INIT =         12;
-enum DT_FINI =         13;
-enum DT_SONAME =       14;
-enum DT_RPATH =        15;
-enum DT_SYMBOLIC =     16;
-enum DT_REL =          17;
-enum DT_RELSZ =        18;
-enum DT_RELENT =       19;
-enum DT_PLTREL =       20;
-enum DT_DEBUG =        21;
-enum DT_TEXTREL =      22;
-enum DT_JMPREL =       23;
-enum DT_BIND_NOW =     24;
-enum DT_INIT_ARRAY =   25;
-enum DT_FINI_ARRAY =   26;
-enum DT_INIT_ARRAYSZ = 27;
-enum DT_FINI_ARRAYSZ = 28;
-enum DT_RUNPATH =      29;
-enum DT_FLAGS =        30;
-enum DT_ENCODING =     32;
-enum DT_PREINIT_ARRAY = 32;
-enum DT_PREINIT_ARRAYSZ = 33;
 enum DT_MAXPOSTAGS =   34;
-enum DT_LOOS =         0x6000000d;
 enum DT_SUNW_AUXILIARY = 0x6000000d;
 enum DT_SUNW_RTLDINF = 0x6000000e;
 enum DT_SUNW_FILTER =  0x6000000f;
 enum DT_SUNW_CAP =     0x60000010;
-enum DT_HIOS =         0x6ffff000;
-enum DT_VALRNGLO =     0x6ffffd00;
-enum DT_CHECKSUM =     0x6ffffdf8;
-enum DT_PLTPADSZ =     0x6ffffdf9;
-enum DT_MOVEENT =      0x6ffffdfa;
-enum DT_MOVESZ =       0x6ffffdfb;
-enum DT_FEATURE_1 =    0x6ffffdfc;
-enum DT_POSFLAG_1 =    0x6ffffdfd;
-enum DT_SYMINSZ =      0x6ffffdfe;
-enum DT_SYMINENT =     0x6ffffdff;
-enum DT_VALRNGHI =     0x6ffffdff;
-enum DT_ADDRRNGLO =    0x6ffffe00;
-enum DT_GNU_HASH =     0x6ffffef5;
-enum DT_CONFIG =       0x6ffffefa;
-enum DT_DEPAUDIT =     0x6ffffefb;
-enum DT_AUDIT =        0x6ffffefc;
-enum DT_PLTPAD =       0x6ffffefd;
-enum DT_MOVETAB =      0x6ffffefe;
-enum DT_SYMINFO =      0x6ffffeff;
-enum DT_ADDRRNGHI =    0x6ffffeff;
-enum DT_VERSYM =       0x6ffffff0;
-enum DT_RELACOUNT =    0x6ffffff9;
-enum DT_RELCOUNT =     0x6ffffffa;
-enum DT_FLAGS_1 =      0x6ffffffb;
-enum DT_VERDEF =       0x6ffffffc;
-enum DT_VERDEFNUM =    0x6ffffffd;
-enum DT_VERNEED =      0x6ffffffe;
-enum DT_VERNEEDNUM =   0x6fffffff;
-enum DT_LOPROC =       0x70000000;
 enum DT_DEPRECATED_SPARC_REGISTER = 0x7000001;
-enum DT_AUXILIARY =    0x7ffffffd;
 enum DT_USED =         0x7ffffffe;
-enum DT_FILTER =       0x7fffffff;
-enum DT_HIPROC =       0x7fffffff;
-
-enum DF_ORIGIN =       0x00000001;
-enum DF_SYMBOLIC =     0x00000002;
-enum DF_TEXTREL =      0x00000004;
-enum DF_BIND_NOW =     0x00000008;
-enum DF_STATIC_TLS =   0x00000010;
 
 enum DF_1_BIND_NOW =   0x00000001;
-enum DF_1_GLOBAL =     0x00000002;
-enum DF_1_NODELETE =   0x00000008;
-enum DF_1_LOADFLTR =   0x00000010;
-enum DF_1_NOOPEN =     0x00000040;
-enum DF_1_NODEFLIB =   0x00000800;
 
 enum NT_PRSTATUS =     1;
 enum NT_FPREGSET =     2;
@@ -402,55 +75,19 @@ enum NT_PROCSTAT_OSREL = 14;
 enum NT_PROCSTAT_PSSTRINGS = 15;
 enum NT_PROCSTAT_AUXV = 16;
 
-enum STB_LOCAL =       0;
-enum STB_GLOBAL =      1;
-enum STB_WEAK =        2;
-enum STB_NUM =         3;
-enum STB_LOOS =        10;
-enum STB_HIOS =        12;
-enum STB_LOPROC =      13;
-enum STB_HIPROC =      15;
-
-enum STT_NOTYPE =      0;
-enum STT_OBJECT =      1;
-enum STT_FUNC =        2;
-enum STT_SECTION =     3;
-enum STT_FILE =        4;
-enum STT_COMMON =      5;
-enum STT_TLS =         6;
-enum STT_NUM =         7;
-enum STT_LOOS =        10;
-enum STT_GNU_IFUNC =   10;
-enum STT_HIOS =        12;
-enum STT_LOPROC =      13;
-enum STT_HIPROC =      15;
-
-enum STV_DEFAULT =     0;
-enum STV_INTERNAL =    1;
-enum STV_HIDDEN =      2;
-enum STV_PROTECTED =   3;
 enum STV_EXPORTED =    4;
 enum STV_SINGLETON =   5;
 enum STV_ELIMINATE =   6;
 
-enum STN_UNDEF =       0;
-
-enum VER_DEF_CURRENT = 1;
 alias VER_NDX VER_DEF_IDX;
 
-enum VER_FLG_BASE =    0x1;
-enum VER_FLG_WEAK =    0x2;
-
-enum VER_NEED_CURRENT = 1;
 enum VER_NEED_WEAK =    32768;
 enum VER_NEED_HIDDEN = VER_NDX_HIDDEN;
 alias VER_NDX VER_NEED_IDX;
 
-enum VER_NDX_LOCAL =           0;
-enum VER_NDX_GLOBAL =          1;
 enum VER_NDX_GIVEN =           2;
-
 enum VER_NDX_HIDDEN =      32768;
+
 extern (D)
 {
     auto VER_NDX(V)(V v) { return v & ~(1u << 15); }
@@ -460,420 +97,28 @@ enum CA_SUNW_NULL =    0;
 enum CA_SUNW_HW_1 =    1;
 enum CA_SUNW_SF_1 =    2;
 
-enum SYMINFO_FLG_DIRECT =      0x0001;
-enum SYMINFO_FLG_PASSTHRU =    0x0002;
-enum SYMINFO_FLG_COPY =        0x0004;
-enum SYMINFO_FLG_LAZYLOAD =    0x0008;
 enum SYMINFO_FLG_DIRECTBIND =  0x0010;
 enum SYMINFO_FLG_NOEXTDIRECT = 0x0020;
 enum SYMINFO_FLG_FILTER =      0x0002;
 enum SYMINFO_FLG_AUXILIARY =   0x0040;
 
-enum SYMINFO_BT_SELF =         0xffff;
-enum SYMINFO_BT_PARENT =       0xfffe;
 enum SYMINFO_BT_NONE =         0xfffd;
 enum SYMINFO_BT_EXTERN =       0xfffc;
-enum SYMINFO_BT_LOWRESERVE =   0xff00;
-
-enum SYMINFO_NONE =            0;
-enum SYMINFO_CURRENT =         1;
-enum SYMINFO_NUM =             2;
-
-enum R_386_NONE =               0;
-enum R_386_32 =                 1;
-enum R_386_PC32 =               2;
-enum R_386_GOT32 =              3;
-enum R_386_PLT32 =              4;
-enum R_386_COPY =               5;
-enum R_386_GLOB_DAT =           6;
-enum R_386_JMP_SLOT =           7;
-enum R_386_RELATIVE =           8;
-enum R_386_GOTOFF =             9;
-enum R_386_GOTPC =              10;
-enum R_386_TLS_TPOFF =          14;
-enum R_386_TLS_IE =             15;
-enum R_386_TLS_GOTIE =          16;
-enum R_386_TLS_LE =             17;
-enum R_386_TLS_GD =             18;
-enum R_386_TLS_LDM =            19;
-enum R_386_TLS_GD_32 =          24;
-enum R_386_TLS_GD_PUSH =        25;
-enum R_386_TLS_GD_CALL =        26;
-enum R_386_TLS_GD_POP =         27;
-enum R_386_TLS_LDM_32 =         28;
-enum R_386_TLS_LDM_PUSH =       29;
-enum R_386_TLS_LDM_CALL =       30;
-enum R_386_TLS_LDM_POP =        31;
-enum R_386_TLS_LDO_32 =         32;
-enum R_386_TLS_IE_32 =          33;
-enum R_386_TLS_LE_32 =          34;
-enum R_386_TLS_DTPMOD32 =       35;
-enum R_386_TLS_DTPOFF32 =       36;
-enum R_386_TLS_TPOFF32 =        37;
-enum R_386_IRELATIVE =          42;
-
-enum R_ARM_NONE =               0;
-enum R_ARM_PC24 =               1;
-enum R_ARM_ABS32 =              2;
-enum R_ARM_REL32 =              3;
-enum R_ARM_PC13 =               4;
-enum R_ARM_ABS16 =              5;
-enum R_ARM_ABS12 =              6;
-enum R_ARM_THM_ABS5 =           7;
-enum R_ARM_ABS8 =               8;
-enum R_ARM_SBREL32 =            9;
-enum R_ARM_THM_PC22 =           10;
-enum R_ARM_THM_PC8 =            11;
-enum R_ARM_AMP_VCALL9 =         12;
-enum R_ARM_SWI24 =              13;
-enum R_ARM_THM_SWI8 =           14;
-enum R_ARM_XPC25 =              15;
-enum R_ARM_THM_XPC22 =          16;
-enum R_ARM_TLS_DTPMOD32 =       17;
-enum R_ARM_TLS_DTPOFF32 =       18;
-enum R_ARM_TLS_TPOFF32 =        19;
-enum R_ARM_COPY =               20;
-enum R_ARM_GLOB_DAT =           21;
-enum R_ARM_JUMP_SLOT =          22;
-enum R_ARM_RELATIVE =           23;
-enum R_ARM_GOTOFF =             24;
-enum R_ARM_GOTPC =              25;
-enum R_ARM_GOT32 =              26;
-enum R_ARM_PLT32 =              27;
-enum R_ARM_GNU_VTENTRY =        100;
-enum R_ARM_GNU_VTINHERIT =      101;
-enum R_ARM_RSBREL32 =           250;
-enum R_ARM_THM_RPC22 =          251;
-enum R_ARM_RREL32 =             252;
-enum R_ARM_RABS32 =             253;
-enum R_ARM_RPC24 =              254;
-enum R_ARM_RBASE =              255;
-
-enum R_IA_64_NONE =             0;
-enum R_IA_64_IMM14 =            0x21;
-enum R_IA_64_IMM22 =            0x22;
-enum R_IA_64_IMM64 =            0x23;
-enum R_IA_64_DIR32MSB =         0x24;
-enum R_IA_64_DIR32LSB =         0x25;
-enum R_IA_64_DIR64MSB =         0x26;
-enum R_IA_64_DIR64LSB =         0x27;
-enum R_IA_64_GPREL22 =          0x2a;
-enum R_IA_64_GPREL64I =         0x2b;
-enum R_IA_64_GPREL32MSB =       0x2c;
-enum R_IA_64_GPREL32LSB =       0x2d;
-enum R_IA_64_GPREL64MSB =       0x2e;
-enum R_IA_64_GPREL64LSB =       0x2f;
-enum R_IA_64_LTOFF22 =          0x32;
-enum R_IA_64_LTOFF64I =         0x33;
-enum R_IA_64_PLTOFF22 =         0x3a;
-enum R_IA_64_PLTOFF64I =        0x3b;
-enum R_IA_64_PLTOFF64MSB =      0x3e;
-enum R_IA_64_PLTOFF64LSB =      0x3f;
-enum R_IA_64_FPTR64I =          0x43;
-enum R_IA_64_FPTR32MSB =        0x44;
-enum R_IA_64_FPTR32LSB =        0x45;
-enum R_IA_64_FPTR64MSB =        0x46;
-enum R_IA_64_FPTR64LSB =        0x47;
-enum R_IA_64_PCREL60B =         0x48;
-enum R_IA_64_PCREL21B =         0x49;
-enum R_IA_64_PCREL21M =         0x4a;
-enum R_IA_64_PCREL21F =         0x4b;
-enum R_IA_64_PCREL32MSB =       0x4c;
-enum R_IA_64_PCREL32LSB =       0x4d;
-enum R_IA_64_PCREL64MSB =       0x4e;
-enum R_IA_64_PCREL64LSB =       0x4f;
-enum R_IA_64_LTOFF_FPTR22 =     0x52;
-enum R_IA_64_LTOFF_FPTR64I =    0x53;
-enum R_IA_64_LTOFF_FPTR32MSB =  0x54;
-enum R_IA_64_LTOFF_FPTR32LSB =  0x55;
-enum R_IA_64_LTOFF_FPTR64MSB =  0x56;
-enum R_IA_64_LTOFF_FPTR64LSB =  0x57;
-enum R_IA_64_SEGREL32MSB =      0x5c;
-enum R_IA_64_SEGREL32LSB =      0x5d;
-enum R_IA_64_SEGREL64MSB =      0x5e;
-enum R_IA_64_SEGREL64LSB =      0x5f;
-enum R_IA_64_SECREL32MSB =      0x64;
-enum R_IA_64_SECREL32LSB =      0x65;
-enum R_IA_64_SECREL64MSB =      0x66;
-enum R_IA_64_SECREL64LSB =      0x67;
-enum R_IA_64_REL32MSB =         0x6c;
-enum R_IA_64_REL32LSB =         0x6d;
-enum R_IA_64_REL64MSB =         0x6e;
-enum R_IA_64_REL64LSB =         0x6f;
-enum R_IA_64_LTV32MSB =         0x74;
-enum R_IA_64_LTV32LSB =         0x75;
-enum R_IA_64_LTV64MSB =         0x76;
-enum R_IA_64_LTV64LSB =         0x77;
-enum R_IA_64_PCREL21BI =        0x79;
-enum R_IA_64_PCREL22 =          0x7a;
-enum R_IA_64_PCREL64I =         0x7b;
-enum R_IA_64_IPLTMSB =          0x80;
-enum R_IA_64_IPLTLSB =          0x81;
-enum R_IA_64_SUB =              0x85;
-enum R_IA_64_LTOFF22X =         0x86;
-enum R_IA_64_LDXMOV =           0x87;
-enum R_IA_64_TPREL14 =          0x91;
-enum R_IA_64_TPREL22 =          0x92;
-enum R_IA_64_TPREL64I =         0x93;
-enum R_IA_64_TPREL64MSB =       0x96;
-enum R_IA_64_TPREL64LSB =       0x97;
-enum R_IA_64_LTOFF_TPREL22 =    0x9a;
-enum R_IA_64_DTPMOD64MSB =      0xa6;
-enum R_IA_64_DTPMOD64LSB =      0xa7;
-enum R_IA_64_LTOFF_DTPMOD22 =   0xaa;
-enum R_IA_64_DTPREL14 =         0xb1;
-enum R_IA_64_DTPREL22 =         0xb2;
-enum R_IA_64_DTPREL64I =        0xb3;
-enum R_IA_64_DTPREL32MSB =      0xb4;
-enum R_IA_64_DTPREL32LSB =      0xb5;
-enum R_IA_64_DTPREL64MSB =      0xb6;
-enum R_IA_64_DTPREL64LSB =      0xb7;
-enum R_IA_64_LTOFF_DTPREL22 =   0xba;
-
-enum R_MIPS_NONE =              0;
-enum R_MIPS_16 =                1;
-enum R_MIPS_32 =                2;
-enum R_MIPS_REL32 =             3;
-enum R_MIPS_26 =                4;
-enum R_MIPS_HI16 =              5;
-enum R_MIPS_LO16 =              6;
-enum R_MIPS_GPREL16 =           7;
-enum R_MIPS_LITERAL =           8;
-enum R_MIPS_GOT16 =             9;
-enum R_MIPS_PC16 =              10;
-enum R_MIPS_CALL16 =            11;
-enum R_MIPS_GPREL32 =           12;
-enum R_MIPS_GOTHI16 =           21;
-enum R_MIPS_GOTLO16 =           22;
-enum R_MIPS_CALLHI16 =          30;
-enum R_MIPS_CALLLO16 =          31;
-
-enum R_PPC_NONE =               0;
-enum R_PPC_ADDR32 =             1;
-enum R_PPC_ADDR24 =             2;
-enum R_PPC_ADDR16 =             3;
-enum R_PPC_ADDR16_LO =          4;
-enum R_PPC_ADDR16_HI =          5;
-enum R_PPC_ADDR16_HA =          6;
-enum R_PPC_ADDR14 =             7;
-enum R_PPC_ADDR14_BRTAKEN =     8;
-enum R_PPC_ADDR14_BRNTAKEN =    9;
-enum R_PPC_REL24 =              10;
-enum R_PPC_REL14 =              11;
-enum R_PPC_REL14_BRTAKEN =      12;
-enum R_PPC_REL14_BRNTAKEN =     13;
-enum R_PPC_GOT16 =              14;
-enum R_PPC_GOT16_LO =           15;
-enum R_PPC_GOT16_HI =           16;
-enum R_PPC_GOT16_HA =           17;
-enum R_PPC_PLTREL24 =           18;
-enum R_PPC_COPY =               19;
-enum R_PPC_GLOB_DAT =           20;
-enum R_PPC_JMP_SLOT =           21;
-enum R_PPC_RELATIVE =           22;
-enum R_PPC_LOCAL24PC =          23;
-enum R_PPC_UADDR32 =            24;
-enum R_PPC_UADDR16 =            25;
-enum R_PPC_REL32 =              26;
-enum R_PPC_PLT32 =              27;
-enum R_PPC_PLTREL32 =           28;
-enum R_PPC_PLT16_LO =           29;
-enum R_PPC_PLT16_HI =           30;
-enum R_PPC_PLT16_HA =           31;
-enum R_PPC_SDAREL16 =           32;
-enum R_PPC_SECTOFF =            33;
-enum R_PPC_SECTOFF_LO =         34;
-enum R_PPC_SECTOFF_HI =         35;
-enum R_PPC_SECTOFF_HA =         36;
-
-enum R_PPC64_ADDR64 =           38;
-enum R_PPC64_ADDR16_HIGHER =    39;
-enum R_PPC64_ADDR16_HIGHERA =   40;
-enum R_PPC64_ADDR16_HIGHEST =   41;
-enum R_PPC64_ADDR16_HIGHESTA =  42;
-enum R_PPC64_UADDR64 =          43;
-enum R_PPC64_REL64 =            44;
-enum R_PPC64_PLT64 =            45;
-enum R_PPC64_PLTREL64 =         46;
-enum R_PPC64_TOC16 =            47;
-enum R_PPC64_TOC16_LO =         48;
-enum R_PPC64_TOC16_HI =         49;
-enum R_PPC64_TOC16_HA =         50;
-enum R_PPC64_TOC =              51;
-enum R_PPC64_DTPMOD64 =         68;
-enum R_PPC64_TPREL64 =          73;
-enum R_PPC64_DTPREL64 =         78;
-
-enum R_PPC_TLS =                67;
-enum R_PPC_DTPMOD32 =           68;
-enum R_PPC_TPREL16 =            69;
-enum R_PPC_TPREL16_LO =         70;
-enum R_PPC_TPREL16_HI =         71;
-enum R_PPC_TPREL16_HA =         72;
-enum R_PPC_TPREL32 =            73;
-enum R_PPC_DTPREL16 =           74;
-enum R_PPC_DTPREL16_LO =        75;
-enum R_PPC_DTPREL16_HI =        76;
-enum R_PPC_DTPREL16_HA =        77;
-enum R_PPC_DTPREL32 =           78;
-enum R_PPC_GOT_TLSGD16 =        79;
-enum R_PPC_GOT_TLSGD16_LO =     80;
-enum R_PPC_GOT_TLSGD16_HI =     81;
-enum R_PPC_GOT_TLSGD16_HA =     82;
-enum R_PPC_GOT_TLSLD16 =        83;
-enum R_PPC_GOT_TLSLD16_LO =     84;
-enum R_PPC_GOT_TLSLD16_HI =     85;
-enum R_PPC_GOT_TLSLD16_HA =     86;
-enum R_PPC_GOT_TPREL16 =        87;
-enum R_PPC_GOT_TPREL16_LO =     88;
-enum R_PPC_GOT_TPREL16_HI =     89;
-enum R_PPC_GOT_TPREL16_HA =     90;
-
-enum R_PPC_EMB_NADDR32 =        101;
-enum R_PPC_EMB_NADDR16 =        102;
-enum R_PPC_EMB_NADDR16_LO =     103;
-enum R_PPC_EMB_NADDR16_HI =     104;
-enum R_PPC_EMB_NADDR16_HA =     105;
-enum R_PPC_EMB_SDAI16 =         106;
-enum R_PPC_EMB_SDA2I16 =        107;
-enum R_PPC_EMB_SDA2REL =        108;
-enum R_PPC_EMB_SDA21 =          109;
-enum R_PPC_EMB_MRKREF =         110;
-enum R_PPC_EMB_RELSEC16 =       111;
-enum R_PPC_EMB_RELST_LO =       112;
-enum R_PPC_EMB_RELST_HI =       113;
-enum R_PPC_EMB_RELST_HA =       114;
-enum R_PPC_EMB_BIT_FLD =        115;
-enum R_PPC_EMB_RELSDA =         116;
-
-enum R_SPARC_NONE =             0;
-enum R_SPARC_8 =                1;
-enum R_SPARC_16 =               2;
-enum R_SPARC_32 =               3;
-enum R_SPARC_DISP8 =            4;
-enum R_SPARC_DISP16 =           5;
-enum R_SPARC_DISP32 =           6;
-enum R_SPARC_WDISP30 =          7;
-enum R_SPARC_WDISP22 =          8;
-enum R_SPARC_HI22 =             9;
-enum R_SPARC_22 =               10;
-enum R_SPARC_13 =               11;
-enum R_SPARC_LO10 =             12;
-enum R_SPARC_GOT10 =            13;
-enum R_SPARC_GOT13 =            14;
-enum R_SPARC_GOT22 =            15;
-enum R_SPARC_PC10 =             16;
-enum R_SPARC_PC22 =             17;
-enum R_SPARC_WPLT30 =           18;
-enum R_SPARC_COPY =             19;
-enum R_SPARC_GLOB_DAT =         20;
-enum R_SPARC_JMP_SLOT =         21;
-enum R_SPARC_RELATIVE =         22;
-enum R_SPARC_UA32 =             23;
-enum R_SPARC_PLT32 =            24;
-enum R_SPARC_HIPLT22 =          25;
-enum R_SPARC_LOPLT10 =          26;
-enum R_SPARC_PCPLT32 =          27;
-enum R_SPARC_PCPLT22 =          28;
-enum R_SPARC_PCPLT10 =          29;
-enum R_SPARC_10 =               30;
-enum R_SPARC_11 =               31;
-enum R_SPARC_64 =               32;
-enum R_SPARC_OLO10 =            33;
-enum R_SPARC_HH22 =             34;
-enum R_SPARC_HM10 =             35;
-enum R_SPARC_LM22 =             36;
-enum R_SPARC_PC_HH22 =          37;
-enum R_SPARC_PC_HM10 =          38;
-enum R_SPARC_PC_LM22 =          39;
-enum R_SPARC_WDISP16 =          40;
-enum R_SPARC_WDISP19 =          41;
-enum R_SPARC_GLOB_JMP =         42;
-enum R_SPARC_7 =                43;
-enum R_SPARC_5 =                44;
-enum R_SPARC_6 =                45;
-enum R_SPARC_DISP64 =           46;
-enum R_SPARC_PLT64 =            47;
-enum R_SPARC_HIX22 =            48;
-enum R_SPARC_LOX10 =            49;
-enum R_SPARC_H44 =              50;
-enum R_SPARC_M44 =              51;
-enum R_SPARC_L44 =              52;
-enum R_SPARC_REGISTER =         53;
-enum R_SPARC_UA64 =             54;
-enum R_SPARC_UA16 =             55;
-enum R_SPARC_TLS_GD_HI22 =      56;
-enum R_SPARC_TLS_GD_LO10 =      57;
-enum R_SPARC_TLS_GD_ADD =       58;
-enum R_SPARC_TLS_GD_CALL =      59;
-enum R_SPARC_TLS_LDM_HI22 =     60;
-enum R_SPARC_TLS_LDM_LO10 =     61;
-enum R_SPARC_TLS_LDM_ADD =      62;
-enum R_SPARC_TLS_LDM_CALL =     63;
-enum R_SPARC_TLS_LDO_HIX22 =    64;
-enum R_SPARC_TLS_LDO_LOX10 =    65;
-enum R_SPARC_TLS_LDO_ADD =      66;
-enum R_SPARC_TLS_IE_HI22 =      67;
-enum R_SPARC_TLS_IE_LO10 =      68;
-enum R_SPARC_TLS_IE_LD =        69;
-enum R_SPARC_TLS_IE_LDX =       70;
-enum R_SPARC_TLS_IE_ADD =       71;
-enum R_SPARC_TLS_LE_HIX22 =     72;
-enum R_SPARC_TLS_LE_LOX10 =     73;
-enum R_SPARC_TLS_DTPMOD32 =     74;
-enum R_SPARC_TLS_DTPMOD64 =     75;
-enum R_SPARC_TLS_DTPOFF32 =     76;
-enum R_SPARC_TLS_DTPOFF64 =     77;
-enum R_SPARC_TLS_TPOFF32 =      78;
-enum R_SPARC_TLS_TPOFF64 =      79;
-
-enum R_X86_64_NONE =            0;
-enum R_X86_64_64 =              1;
-enum R_X86_64_PC32 =            2;
-enum R_X86_64_GOT32 =           3;
-enum R_X86_64_PLT32 =           4;
-enum R_X86_64_COPY =            5;
-enum R_X86_64_GLOB_DAT =        6;
-enum R_X86_64_JMP_SLOT =        7;
-enum R_X86_64_RELATIVE =        8;
-enum R_X86_64_GOTPCREL =        9;
-enum R_X86_64_32 =              10;
-enum R_X86_64_32S =             11;
-enum R_X86_64_16 =              12;
-enum R_X86_64_PC16 =            13;
-enum R_X86_64_8 =               14;
-enum R_X86_64_PC8 =             15;
-enum R_X86_64_DTPMOD64 =        16;
-enum R_X86_64_DTPOFF64 =        17;
-enum R_X86_64_TPOFF64 =         18;
-enum R_X86_64_TLSGD =           19;
-enum R_X86_64_TLSLD =           20;
-enum R_X86_64_DTPOFF32 =        21;
-enum R_X86_64_GOTTPOFF =        22;
-enum R_X86_64_TPOFF32 =         23;
-enum R_X86_64_IRELATIVE =       37;
 
 version (PPC64)
 {
-enum __ELF_WORD_SIZE = 64;
-enum ELF_ARCH = EM_PPC64;
-enum ELF_MACHINE_OK(x) = ((x) == EM_PPC64);
+    enum __ELF_WORD_SIZE = 64;
+    enum ELF_ARCH = EM_PPC64;
+    enum ELF_MACHINE_OK(x) = ((x) == EM_PPC64);
 }
 version (PPC)
 {
-enum __ELF_WORD_SIZE = 32;
-enum ELF_ARCH = EM_PPC;
-enum ELF_ARCH32 = EM_PPC;
-enum ELF_MACHINE_OK(x) = ((x) == EM_PPC);
+    enum __ELF_WORD_SIZE = 32;
+    enum ELF_ARCH = EM_PPC;
+    enum ELF_ARCH32 = EM_PPC;
+    enum ELF_MACHINE_OK(x) = ((x) == EM_PPC);
 }
 
-/**
- * Auxiliary vector entries for passing information to the interpreter.
- *
- * The PowerPC supplement to the SVR4 ABI specification names this "auxv_t",
- * but POSIX lays claim to all symbols ending with "_t".
- */
-
 struct Elf32_Auxinfo
 {
     int a_type;
@@ -896,12 +141,6 @@ struct Elf64_Auxinfo
     }
 }
 
-// __ElfType(Auxinfo);
-
-/**
- * Values for a_type.
- */
-
 enum AT_NULL   = 0;
 enum AT_IGNORE = 1;
 enum AT_EXECFD = 2;
@@ -926,31 +165,23 @@ enum AT_STACKPROT = 21;
 enum AT_TIMEKEEP  = 22;
 enum AT_COUNT = 23;
 
-/**
- * Relocation types.
- */
-
 enum R_PPC_COUNT =  37;
 enum R_PPC_EMB_COUNT =  (R_PPC_EMB_RELSDA - R_PPC_EMB_NADDR32 + 1);
 
-/**
- * Define "machine" characteristics
- */
-
 version (PPC64)
 {
-enum ELF_TARG_CLASS =   ELFCLASS64;
-enum ELF_TARG_DATA =    ELFDATA2MSB;
-enum ELF_TARG_MACH =    EM_PPC64;
-enum ELF_TARG_VER =     1;
+    enum ELF_TARG_CLASS =   ELFCLASS64;
+    enum ELF_TARG_DATA =    ELFDATA2MSB;
+    enum ELF_TARG_MACH =    EM_PPC64;
+    enum ELF_TARG_VER =     1;
 }
 
 version (PPC)
 {
-enum ELF_TARG_CLASS =   ELFCLASS32;
-enum ELF_TARG_DATA =    ELFDATA2MSB;
-enum ELF_TARG_MACH =    EM_PPC;
-enum ELF_TARG_VER =     1;
+    enum ELF_TARG_CLASS =   ELFCLASS32;
+    enum ELF_TARG_DATA =    ELFDATA2MSB;
+    enum ELF_TARG_MACH =    EM_PPC;
+    enum ELF_TARG_VER =     1;
 }
 
 enum ET_DYN_LOAD_ADDR = 0x01010000;
index 4d0b2273117846c059e2477e9d6f6b9e4a494f9d..2cd933170a134dc257a443a38245473baea3377d 100644 (file)
@@ -12,494 +12,28 @@ nothrow:
 @system:
 
 import core.stdc.stdint;
-
-alias uint16_t Elf32_Half;
-alias uint16_t Elf64_Half;
-
-alias uint32_t Elf32_Word;
-alias int32_t  Elf32_Sword;
-alias uint32_t Elf64_Word;
-alias int32_t  Elf64_Sword;
-
-alias uint64_t Elf32_Xword;
-alias int64_t  Elf32_Sxword;
-alias uint64_t Elf64_Xword;
-alias int64_t  Elf64_Sxword;
-
-alias uint32_t Elf32_Addr;
-alias uint64_t Elf64_Addr;
-
-alias uint32_t Elf32_Off;
-alias uint64_t Elf64_Off;
-
-alias uint16_t Elf32_Section;
-alias uint16_t Elf64_Section;
-
-alias Elf32_Half Elf32_Versym;
-alias Elf64_Half Elf64_Versym;
-
-
-enum EI_NIDENT = 16;
-
-struct Elf32_Ehdr
-{
-    char[EI_NIDENT] e_ident = 0;
-    Elf32_Half    e_type;
-    Elf32_Half    e_machine;
-    Elf32_Word    e_version;
-    Elf32_Addr    e_entry;
-    Elf32_Off     e_phoff;
-    Elf32_Off     e_shoff;
-    Elf32_Word    e_flags;
-    Elf32_Half    e_ehsize;
-    Elf32_Half    e_phentsize;
-    Elf32_Half    e_phnum;
-    Elf32_Half    e_shentsize;
-    Elf32_Half    e_shnum;
-    Elf32_Half    e_shstrndx;
-}
-
-struct Elf64_Ehdr
-{
-    char[EI_NIDENT] e_ident = 0;
-    Elf64_Half    e_type;
-    Elf64_Half    e_machine;
-    Elf64_Word    e_version;
-    Elf64_Addr    e_entry;
-    Elf64_Off     e_phoff;
-    Elf64_Off     e_shoff;
-    Elf64_Word    e_flags;
-    Elf64_Half    e_ehsize;
-    Elf64_Half    e_phentsize;
-    Elf64_Half    e_phnum;
-    Elf64_Half    e_shentsize;
-    Elf64_Half    e_shnum;
-    Elf64_Half    e_shstrndx;
-}
-
-enum EI_MAG0 =         0;
-enum ELFMAG0 =         0x7f;
-
-enum EI_MAG1 =         1;
-enum ELFMAG1 =         'E';
-
-enum EI_MAG2 =         2;
-enum ELFMAG2 =         'L';
-
-enum EI_MAG3 =         3;
-enum ELFMAG3 =         'F';
-enum ELFMAG =          "\177ELF";
-enum SELFMAG =         4;
-
-enum EI_CLASS =        4;
-enum ELFCLASSNONE =    0;
-enum ELFCLASS32 =      1;
-enum ELFCLASS64 =      2;
-enum ELFCLASSNUM =     3;
-
-enum EI_DATA =         5;
-enum ELFDATANONE =     0;
-enum ELFDATA2LSB =     1;
-enum ELFDATA2MSB =     2;
-enum ELFDATANUM =      3;
-
-enum EI_VERSION =      6;
-
-enum EI_OSABI =        7;
-enum ELFOSABI_NONE =           0;
-enum ELFOSABI_SYSV =           0;
-enum ELFOSABI_HPUX =           1;
-enum ELFOSABI_NETBSD =         2;
-enum ELFOSABI_GNU =            3;
-enum ELFOSABI_LINUX =          ELFOSABI_GNU;
-enum ELFOSABI_SOLARIS =        6;
-enum ELFOSABI_AIX =            7;
-enum ELFOSABI_IRIX =           8;
-enum ELFOSABI_FREEBSD =        9;
-enum ELFOSABI_TRU64 =          10;
-enum ELFOSABI_MODESTO =        11;
-enum ELFOSABI_OPENBSD =        12;
-enum ELFOSABI_ARM_AEABI =      64;
-enum ELFOSABI_ARM =            97;
-enum ELFOSABI_STANDALONE =     255;
-enum ELFOSABI_DRAGONFLYBSD =   ELFOSABI_NONE;
-
-enum EI_ABIVERSION =   8;
-
-enum EI_PAD =          9;
-
-enum ET_NONE =         0;
-enum ET_REL =          1;
-enum ET_EXEC =         2;
-enum ET_DYN =          3;
-enum ET_CORE =         4;
-enum ET_NUM =          5;
-enum ET_LOOS =         0xfe00;
-enum ET_HIOS =         0xfeff;
-enum ET_LOPROC =       0xff00;
-enum ET_HIPROC =       0xffff;
-
-enum EM_NONE =          0;
-enum EM_M32 =           1;
-enum EM_SPARC =         2;
-enum EM_386 =           3;
-enum EM_68K =           4;
-enum EM_88K =           5;
-enum EM_860 =           7;
-enum EM_MIPS =          8;
-enum EM_S370 =          9;
-enum EM_MIPS_RS3_LE =  10;
-
-enum EM_PARISC =       15;
-enum EM_VPP500 =       17;
-enum EM_SPARC32PLUS =  18;
-enum EM_960 =          19;
-enum EM_PPC =          20;
-enum EM_PPC64 =        21;
-enum EM_S390 =         22;
-
-enum EM_V800 =         36;
-enum EM_FR20 =         37;
-enum EM_RH32 =         38;
-enum EM_RCE =          39;
-enum EM_ARM =          40;
-enum EM_FAKE_ALPHA =   41;
-enum EM_SH =           42;
-enum EM_SPARCV9 =      43;
-enum EM_TRICORE =      44;
-enum EM_ARC =          45;
-enum EM_H8_300 =       46;
-enum EM_H8_300H =      47;
-enum EM_H8S =          48;
-enum EM_H8_500 =       49;
-enum EM_IA_64 =        50;
-enum EM_MIPS_X =       51;
-enum EM_COLDFIRE =     52;
-enum EM_68HC12 =       53;
-enum EM_MMA =          54;
-enum EM_PCP =          55;
-enum EM_NCPU =         56;
-enum EM_NDR1 =         57;
-enum EM_STARCORE =     58;
-enum EM_ME16 =         59;
-enum EM_ST100 =        60;
-enum EM_TINYJ =        61;
-enum EM_X86_64 =       62;
-enum EM_PDSP =         63;
-
-enum EM_FX66 =         66;
-enum EM_ST9PLUS =      67;
-enum EM_ST7 =          68;
-enum EM_68HC16 =       69;
-enum EM_68HC11 =       70;
-enum EM_68HC08 =       71;
-enum EM_68HC05 =       72;
-enum EM_SVX =          73;
-enum EM_ST19 =         74;
-enum EM_VAX =          75;
-enum EM_CRIS =         76;
-enum EM_JAVELIN =      77;
-enum EM_FIREPATH =     78;
-enum EM_ZSP =          79;
-enum EM_MMIX =         80;
-enum EM_HUANY =        81;
-enum EM_PRISM =        82;
-enum EM_AVR =          83;
-enum EM_FR30 =         84;
-enum EM_D10V =         85;
-enum EM_D30V =         86;
-enum EM_V850 =         87;
-enum EM_M32R =         88;
-enum EM_MN10300 =      89;
-enum EM_MN10200 =      90;
-enum EM_PJ =           91;
-enum EM_OPENRISC =     92;
-enum EM_ARC_A5 =       93;
-enum EM_XTENSA =       94;
-enum EM_AARCH64 =      183;
-enum EM_TILEPRO =      188;
-enum EM_TILEGX =       191;
-enum EM_NUM =          192;
-
-enum EM_ALPHA =        0x9026;
-
-enum EV_NONE =         0;
-enum EV_CURRENT =      1;
-enum EV_NUM =          2;
-
-struct Elf32_Shdr
-{
-  Elf32_Word    sh_name;
-  Elf32_Word    sh_type;
-  Elf32_Word    sh_flags;
-  Elf32_Addr    sh_addr;
-  Elf32_Off     sh_offset;
-  Elf32_Word    sh_size;
-  Elf32_Word    sh_link;
-  Elf32_Word    sh_info;
-  Elf32_Word    sh_addralign;
-  Elf32_Word    sh_entsize;
-}
-
-struct Elf64_Shdr
-{
-  Elf64_Word    sh_name;
-  Elf64_Word    sh_type;
-  Elf64_Xword   sh_flags;
-  Elf64_Addr    sh_addr;
-  Elf64_Off     sh_offset;
-  Elf64_Xword   sh_size;
-  Elf64_Word    sh_link;
-  Elf64_Word    sh_info;
-  Elf64_Xword   sh_addralign;
-  Elf64_Xword   sh_entsize;
-}
-
-enum SHN_UNDEF =       0;
-enum SHN_LORESERVE =   0xff00;
-enum SHN_LOPROC =      0xff00;
-enum SHN_BEFORE =      0xff00;
-enum SHN_AFTER =       0xff01;
-enum SHN_HIPROC =      0xff1f;
-enum SHN_LOOS =        0xff20;
-enum SHN_HIOS =        0xff3f;
-enum SHN_ABS =         0xfff1;
-enum SHN_COMMON =      0xfff2;
-enum SHN_XINDEX =      0xffff;
-enum SHN_HIRESERVE =   0xffff;
-
-enum SHT_NULL =          0;
-enum SHT_PROGBITS =      1;
-enum SHT_SYMTAB =        2;
-enum SHT_STRTAB =        3;
-enum SHT_RELA =          4;
-enum SHT_HASH =          5;
-enum SHT_DYNAMIC =       6;
-enum SHT_NOTE =          7;
-enum SHT_NOBITS =        8;
-enum SHT_REL =           9;
-enum SHT_SHLIB =         10;
-enum SHT_DYNSYM =        11;
-enum SHT_INIT_ARRAY =    14;
-enum SHT_FINI_ARRAY =    15;
-enum SHT_PREINIT_ARRAY = 16;
-enum SHT_GROUP =         17;
-enum SHT_SYMTAB_SHNDX =  18;
-enum SHT_NUM =           19;
-enum SHT_LOOS =          0x60000000;
-enum SHT_GNU_ATTRIBUTES = 0x6ffffff5;
-enum SHT_GNU_HASH =      0x6ffffff6;
-enum SHT_GNU_LIBLIST =   0x6ffffff7;
-enum SHT_CHECKSUM =      0x6ffffff8;
-enum SHT_LOSUNW =        0x6ffffffa;
-enum SHT_SUNW_move =     0x6ffffffa;
-enum SHT_SUNW_COMDAT =   0x6ffffffb;
-enum SHT_SUNW_syminfo =  0x6ffffffc;
-enum SHT_GNU_verdef =    0x6ffffffd;
-enum SHT_GNU_verneed =   0x6ffffffe;
-enum SHT_GNU_versym =    0x6fffffff;
-enum SHT_HISUNW =        0x6fffffff;
-enum SHT_HIOS =          0x6fffffff;
-enum SHT_LOPROC =        0x70000000;
-enum SHT_HIPROC =        0x7fffffff;
-enum SHT_LOUSER =        0x80000000;
-enum SHT_HIUSER =        0x8fffffff;
-
-enum SHF_WRITE =            (1 << 0);
-enum SHF_ALLOC =            (1 << 1);
-enum SHF_EXECINSTR =        (1 << 2);
-enum SHF_MERGE =            (1 << 4);
-enum SHF_STRINGS =          (1 << 5);
-enum SHF_INFO_LINK =        (1 << 6);
-enum SHF_LINK_ORDER =       (1 << 7);
-enum SHF_OS_NONCONFORMING = (1 << 8);
-enum SHF_GROUP =            (1 << 9);
-enum SHF_TLS =              (1 << 10);
-enum SHF_COMPRESSED =       (1 << 11);
-enum SHF_MASKOS =           0x0ff00000;
-enum SHF_MASKPROC =         0xf0000000;
-enum SHF_ORDERED =          (1 << 30);
-enum SHF_EXCLUDE =          (1 << 31);
-enum GRP_COMDAT =      0x1;
-
-struct Elf32_Sym
-{
-  Elf32_Word    st_name;
-  Elf32_Addr    st_value;
-  Elf32_Word    st_size;
-  ubyte st_info;
-  ubyte st_other;
-  Elf32_Section st_shndx;
-}
-
-struct Elf64_Sym
-{
-  Elf64_Word    st_name;
-  ubyte st_info;
-  ubyte st_other;
-  Elf64_Section st_shndx;
-  Elf64_Addr    st_value;
-  Elf64_Xword   st_size;
-}
-
-struct Elf32_Syminfo
-{
-  Elf32_Half si_boundto;
-  Elf32_Half si_flags;
-}
-
-struct Elf64_Syminfo
-{
-  Elf64_Half si_boundto;
-  Elf64_Half si_flags;
-}
-enum SYMINFO_BT_SELF =         0xffff;
-enum SYMINFO_BT_PARENT =       0xfffe;
-enum SYMINFO_BT_LOWRESERVE =   0xff00;
-enum SYMINFO_FLG_DIRECT =      0x0001;
-enum SYMINFO_FLG_PASSTHRU =    0x0002;
-enum SYMINFO_FLG_COPY =        0x0004;
-enum SYMINFO_FLG_LAZYLOAD =    0x0008;
-enum SYMINFO_NONE =            0;
-enum SYMINFO_CURRENT =         1;
-enum SYMINFO_NUM =             2;
-
-extern (D)
-{
-    auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
-    auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; }
-    auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); }
-    alias ELF32_ST_BIND ELF64_ST_BIND;
-    alias ELF32_ST_TYPE ELF64_ST_TYPE;
-    alias ELF32_ST_INFO ELF64_ST_INFO;
-}
-
-enum STB_LOCAL =       0;
-enum STB_GLOBAL =      1;
-enum STB_WEAK =        2;
-enum STB_NUM =         3;
-enum STB_LOOS =        10;
-enum STB_GNU_UNIQUE =  10;
-enum STB_HIOS =        12;
-enum STB_LOPROC =      13;
-enum STB_HIPROC =      15;
-
-enum STT_NOTYPE =      0;
-enum STT_OBJECT =      1;
-enum STT_FUNC =        2;
-enum STT_SECTION =     3;
-enum STT_FILE =        4;
-enum STT_COMMON =      5;
-enum STT_TLS =         6;
-enum STT_NUM =         7;
-enum STT_LOOS =        10;
-enum STT_GNU_IFUNC =   10;
-enum STT_HIOS =        12;
-enum STT_LOPROC =      13;
-enum STT_HIPROC =      15;
-
-enum STN_UNDEF =       0;
+public import core.sys.elf;
 
 extern (D)
 {
     auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; }
     alias ELF32_ST_VISIBILITY ELF64_ST_VISIBILITY;
 }
-enum STV_DEFAULT =     0;
-enum STV_INTERNAL =    1;
-enum STV_HIDDEN =      2;
-enum STV_PROTECTED =   3;
-
-struct Elf32_Rel
-{
-  Elf32_Addr    r_offset;
-  Elf32_Word    r_info;
-}
-
-struct Elf64_Rel
-{
-  Elf64_Addr    r_offset;
-  Elf64_Xword   r_info;
-}
 
-struct Elf32_Rela
-{
-  Elf32_Addr    r_offset;
-  Elf32_Word    r_info;
-  Elf32_Sword   r_addend;
-}
-
-struct Elf64_Rela
-{
-  Elf64_Addr    r_offset;
-  Elf64_Xword   r_info;
-  Elf64_Sxword  r_addend;
-}
-
-extern (D)
-{
-    auto ELF32_R_SYM(V)(V val) { return val >> 8; }
-    auto ELF32_R_TYPE(V)(V val) { return val & 0xff; }
-    auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); }
-
-    auto ELF64_R_SYM(I)(I i) { return i >> 32; }
-    auto ELF64_R_TYPE(I)(I i) { return i & 0xffffffff; }
-    auto ELF64_R_INFO(S, T)(S sym, T type) { return (sym << 32) + (type); }
-}
-
-struct Elf32_Phdr
+struct Elf32_Nhdr
 {
-  Elf32_Word    p_type;
-  Elf32_Off     p_offset;
-  Elf32_Addr    p_vaddr;
-  Elf32_Addr    p_paddr;
-  Elf32_Word    p_filesz;
-  Elf32_Word    p_memsz;
-  Elf32_Word    p_flags;
-  Elf32_Word    p_align;
+  Elf32_Word n_namesz;
+  Elf32_Word n_descsz;
+  Elf32_Word n_type;
 }
 
-struct Elf64_Phdr
+struct Elf64_Nhdr
 {
-  Elf64_Word    p_type;
-  Elf64_Word    p_flags;
-  Elf64_Off     p_offset;
-  Elf64_Addr    p_vaddr;
-  Elf64_Addr    p_paddr;
-  Elf64_Xword   p_filesz;
-  Elf64_Xword   p_memsz;
-  Elf64_Xword   p_align;
+  Elf64_Word n_namesz;
+  Elf64_Word n_descsz;
+  Elf64_Word n_type;
 }
 
-enum PN_XNUM =         0xffff;
-
-enum PT_NULL =         0;
-enum PT_LOAD =         1;
-enum PT_DYNAMIC =      2;
-enum PT_INTERP =       3;
-enum PT_NOTE =         4;
-enum PT_SHLIB =        5;
-enum PT_PHDR =         6;
-enum PT_TLS =          7;
-enum PT_NUM =          8;
-enum PT_LOOS =         0x60000000;
-enum PT_GNU_EH_FRAME = 0x6474e550;
-enum PT_GNU_STACK =    0x6474e551;
-enum PT_GNU_RELRO =    0x6474e552;
-enum PT_LOSUNW =       0x6ffffffa;
-enum PT_SUNWBSS =      0x6ffffffa;
-enum PT_SUNWSTACK =    0x6ffffffb;
-enum PT_HISUNW =       0x6fffffff;
-enum PT_HIOS =         0x6fffffff;
-enum PT_LOPROC =       0x70000000;
-enum PT_HIPROC =       0x7fffffff;
-
-enum PF_X =            (1 << 0);
-enum PF_W =            (1 << 1);
-enum PF_R =            (1 << 2);
-enum PF_MASKOS =       0x0ff00000;
-enum PF_MASKPROC =     0xf0000000;
-
 enum NT_PRSTATUS =     1;
 enum NT_FPREGSET =     2;
 enum NT_PRPSINFO =     3;
@@ -541,242 +75,10 @@ enum NT_ARM_HW_WATCH = 0x403;
 
 enum NT_VERSION =      1;
 
-struct Elf32_Dyn
-{
-  Elf32_Sword   d_tag;
-  union _d_un
-  {
-      Elf32_Word d_val;
-      Elf32_Addr d_ptr;
-  } _d_un d_un;
-}
-
-struct Elf64_Dyn
-{
-  Elf64_Sxword  d_tag;
-  union _d_un
-  {
-      Elf64_Xword d_val;
-      Elf64_Addr d_ptr;
-  } _d_un d_un;
-}
-
-enum DT_NULL =         0;
-enum DT_NEEDED =       1;
-enum DT_PLTRELSZ =     2;
-enum DT_PLTGOT =       3;
-enum DT_HASH =         4;
-enum DT_STRTAB =       5;
-enum DT_SYMTAB =       6;
-enum DT_RELA =         7;
-enum DT_RELASZ =       8;
-enum DT_RELAENT =      9;
-enum DT_STRSZ =        10;
-enum DT_SYMENT =       11;
-enum DT_INIT =         12;
-enum DT_FINI =         13;
-enum DT_SONAME =       14;
-enum DT_RPATH =        15;
-enum DT_SYMBOLIC =     16;
-enum DT_REL =          17;
-enum DT_RELSZ =        18;
-enum DT_RELENT =       19;
-enum DT_PLTREL =       20;
-enum DT_DEBUG =        21;
-enum DT_TEXTREL =      22;
-enum DT_JMPREL =       23;
-enum DT_BIND_NOW =     24;
-enum DT_INIT_ARRAY =   25;
-enum DT_FINI_ARRAY =   26;
-enum DT_INIT_ARRAYSZ = 27;
-enum DT_FINI_ARRAYSZ = 28;
-enum DT_RUNPATH =      29;
-enum DT_FLAGS =        30;
-enum DT_ENCODING =     32;
-enum DT_PREINIT_ARRAY = 32;
-enum DT_PREINIT_ARRAYSZ = 33;
-enum DT_NUM =          34;
-enum DT_LOOS =         0x6000000d;
-enum DT_HIOS =         0x6ffff000;
-enum DT_LOPROC =       0x70000000;
-enum DT_HIPROC =       0x7fffffff;
-enum DT_PROCNUM =      DT_MIPS_NUM;
-enum DT_VALRNGLO =     0x6ffffd00;
-enum DT_GNU_PRELINKED = 0x6ffffdf5;
-enum DT_GNU_CONFLICTSZ = 0x6ffffdf6;
-enum DT_GNU_LIBLISTSZ = 0x6ffffdf7;
-enum DT_CHECKSUM =     0x6ffffdf8;
-enum DT_PLTPADSZ =     0x6ffffdf9;
-enum DT_MOVEENT =      0x6ffffdfa;
-enum DT_MOVESZ =       0x6ffffdfb;
-enum DT_FEATURE_1 =    0x6ffffdfc;
-enum DT_POSFLAG_1 =    0x6ffffdfd;
-enum DT_SYMINSZ =      0x6ffffdfe;
-enum DT_SYMINENT =     0x6ffffdff;
-enum DT_VALRNGHI =     0x6ffffdff;
-extern (D) auto DT_VALTAGIDX(T)(T tag)
-{
-    return DT_VALRNGHI - tag;
-}
-enum DT_VALNUM = 12;
-enum DT_ADDRRNGLO =    0x6ffffe00;
-enum DT_GNU_HASH =     0x6ffffef5;
-enum DT_TLSDESC_PLT =  0x6ffffef6;
-enum DT_TLSDESC_GOT =  0x6ffffef7;
-enum DT_GNU_CONFLICT = 0x6ffffef8;
-enum DT_GNU_LIBLIST =  0x6ffffef9;
-enum DT_CONFIG =       0x6ffffefa;
-enum DT_DEPAUDIT =     0x6ffffefb;
-enum DT_AUDIT =        0x6ffffefc;
-enum DT_PLTPAD =       0x6ffffefd;
-enum DT_MOVETAB =      0x6ffffefe;
-enum DT_SYMINFO =      0x6ffffeff;
-enum DT_ADDRRNGHI =    0x6ffffeff;
-extern (D) auto DT_ADDRTAGIDX(T)(T tag)
-{
-    return DT_ADDRRNGHI - tag;
-}
-enum DT_ADDRNUM = 11;
-enum DT_VERSYM =       0x6ffffff0;
-
-enum DT_RELACOUNT =    0x6ffffff9;
-enum DT_RELCOUNT =     0x6ffffffa;
-enum DT_FLAGS_1 =      0x6ffffffb;
-enum DT_VERDEF =       0x6ffffffc;
-enum DT_VERDEFNUM =    0x6ffffffd;
-enum DT_VERNEED =      0x6ffffffe;
-enum DT_VERNEEDNUM =   0x6fffffff;
-extern (D) auto DT_VERSIONTAGIDX(T)(T tag)
-{
-    return DT_VERNEEDNUM - tag;
-}
-enum DT_VERSIONTAGNUM = 16;
-enum DT_AUXILIARY =    0x7ffffffd;
-enum DT_FILTER =       0x7fffffff;
-extern (D) auto DT_EXTRATAGIDX(T)(T tag)
-{
-    return cast(Elf32_Word)(-(cast(Elf32_Sword)(tag) <<1>>1)-1);
-}
-enum DT_EXTRANUM =     3;
-enum DF_ORIGIN =       0x00000001;
-enum DF_SYMBOLIC =     0x00000002;
-enum DF_TEXTREL =      0x00000004;
-enum DF_BIND_NOW =     0x00000008;
-enum DF_STATIC_TLS =   0x00000010;
-enum DF_1_NOW =        0x00000001;
-enum DF_1_GLOBAL =     0x00000002;
-enum DF_1_GROUP =      0x00000004;
-enum DF_1_NODELETE =   0x00000008;
-enum DF_1_LOADFLTR =   0x00000010;
-enum DF_1_INITFIRST =  0x00000020;
-enum DF_1_NOOPEN =     0x00000040;
-enum DF_1_ORIGIN =     0x00000080;
-enum DF_1_DIRECT =     0x00000100;
-enum DF_1_TRANS =      0x00000200;
-enum DF_1_INTERPOSE =  0x00000400;
-enum DF_1_NODEFLIB =   0x00000800;
-enum DF_1_NODUMP =     0x00001000;
-enum DF_1_CONFALT =    0x00002000;
-enum DF_1_ENDFILTEE =  0x00004000;
-enum DF_1_DISPRELDNE = 0x00008000;
-enum DF_1_DISPRELPND = 0x00010000;
-enum DF_1_NODIRECT =   0x00020000;
-enum DF_1_IGNMULDEF =  0x00040000;
-enum DF_1_NOKSYMS =    0x00080000;
-enum DF_1_NOHDR =      0x00100000;
-enum DF_1_EDITED =     0x00200000;
-enum DF_1_NORELOC =    0x00400000;
-enum DF_1_SYMINTPOSE = 0x00800000;
-enum DF_1_GLOBAUDIT =  0x01000000;
-enum DF_1_SINGLETON =  0x02000000;
-enum DTF_1_PARINIT =   0x00000001;
-enum DTF_1_CONFEXP =   0x00000002;
-enum DF_P1_LAZYLOAD =  0x00000001;
-enum DF_P1_GROUPPERM = 0x00000002;
-
-struct Elf32_Verdef
-{
-    Elf32_Half    vd_version;
-    Elf32_Half    vd_flags;
-    Elf32_Half    vd_ndx;
-    Elf32_Half    vd_cnt;
-    Elf32_Word    vd_hash;
-    Elf32_Word    vd_aux;
-    Elf32_Word    vd_next;
-}
-
-struct Elf64_Verdef
-{
-    Elf64_Half    vd_version;
-    Elf64_Half    vd_flags;
-    Elf64_Half    vd_ndx;
-    Elf64_Half    vd_cnt;
-    Elf64_Word    vd_hash;
-    Elf64_Word    vd_aux;
-    Elf64_Word    vd_next;
-}
-enum VER_DEF_NONE =    0;
-enum VER_DEF_CURRENT = 1;
-enum VER_DEF_NUM =     2;
-enum VER_FLG_BASE =    0x1;
-enum VER_FLG_WEAK =    0x2;
-enum VER_NDX_LOCAL =           0;
-enum VER_NDX_GLOBAL =          1;
-enum VER_NDX_LORESERVE =       0xff00;
-enum VER_NDX_ELIMINATE =       0xff01;
-
-struct Elf32_Verdaux
-{
-    Elf32_Word    vda_name;
-    Elf32_Word    vda_next;
-}
-
-struct Elf64_Verdaux
-{
-    Elf64_Word    vda_name;
-    Elf64_Word    vda_next;
-}
-
-struct Elf32_Verneed
-{
-    Elf32_Half    vn_version;
-    Elf32_Half    vn_cnt;
-    Elf32_Word    vn_file;
-    Elf32_Word    vn_aux;
-    Elf32_Word    vn_next;
-}
-
-struct Elf64_Verneed
-{
-    Elf64_Half    vn_version;
-    Elf64_Half    vn_cnt;
-    Elf64_Word    vn_file;
-    Elf64_Word    vn_aux;
-    Elf64_Word    vn_next;
-}
-enum VER_NEED_NONE =    0;
-enum VER_NEED_CURRENT = 1;
-enum VER_NEED_NUM =     2;
-
-struct Elf32_Vernaux
-{
-    Elf32_Word    vna_hash;
-    Elf32_Half    vna_flags;
-    Elf32_Half    vna_other;
-    Elf32_Word    vna_name;
-    Elf32_Word    vna_next;
-}
-
-struct Elf64_Vernaux
-{
-    Elf64_Word    vna_hash;
-    Elf64_Half    vna_flags;
-    Elf64_Half    vna_other;
-    Elf64_Word    vna_name;
-    Elf64_Word    vna_next;
-}
-// duplicate
-// enum VER_FLG_WEAK =    0x2;
+enum NT_GNU_ABI_TAG =      1;
+enum NT_GNU_HWCAP =        2;
+enum NT_GNU_BUILD_ID =     3;
+enum NT_GNU_GOLD_VERSION = 4;
 
 struct Elf32_auxv_t
 {
@@ -836,1698 +138,3 @@ enum AT_L1I_CACHESHAPE =       34;
 enum AT_L1D_CACHESHAPE =       35;
 enum AT_L2_CACHESHAPE =        36;
 enum AT_L3_CACHESHAPE =        37;
-
-struct Elf32_Nhdr
-{
-  Elf32_Word n_namesz;
-  Elf32_Word n_descsz;
-  Elf32_Word n_type;
-}
-
-struct Elf64_Nhdr
-{
-  Elf64_Word n_namesz;
-  Elf64_Word n_descsz;
-  Elf64_Word n_type;
-}
-enum ELF_NOTE_SOLARIS =        "SUNW Solaris";
-enum ELF_NOTE_GNU =            "GNU";
-enum ELF_NOTE_PAGESIZE_HINT =  1;
-enum NT_GNU_ABI_TAG =  1;
-enum ELF_NOTE_ABI =    NT_GNU_ABI_TAG;
-enum ELF_NOTE_OS_LINUX =       0;
-enum ELF_NOTE_OS_GNU =         1;
-enum ELF_NOTE_OS_SOLARIS2 =    2;
-enum ELF_NOTE_OS_FREEBSD =     3;
-enum NT_GNU_HWCAP =    2;
-enum NT_GNU_BUILD_ID = 3;
-enum NT_GNU_GOLD_VERSION =     4;
-struct Elf32_Move
-{
-  Elf32_Xword m_value;
-  Elf32_Word m_info;
-  Elf32_Word m_poffset;
-  Elf32_Half m_repeat;
-  Elf32_Half m_stride;
-}
-
-struct Elf64_Move
-{
-  Elf64_Xword m_value;
-  Elf64_Xword m_info;
-  Elf64_Xword m_poffset;
-  Elf64_Half m_repeat;
-  Elf64_Half m_stride;
-}
-extern (D)
-{
-    auto ELF32_M_SYM(I)(I info) { return info >> 8; }
-    auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; }
-    auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; }
-}
-
-alias ELF32_M_SYM ELF64_M_SYM;
-alias ELF32_M_SIZE ELF64_M_SIZE;
-alias ELF32_M_INFO ELF64_M_INFO;
-enum EF_CPU32 =        0x00810000;
-
-enum R_68K_NONE =      0;
-enum R_68K_32 =        1;
-enum R_68K_16 =        2;
-enum R_68K_8 =         3;
-enum R_68K_PC32 =      4;
-enum R_68K_PC16 =      5;
-enum R_68K_PC8 =       6;
-enum R_68K_GOT32 =     7;
-enum R_68K_GOT16 =     8;
-enum R_68K_GOT8 =      9;
-enum R_68K_GOT32O =    10;
-enum R_68K_GOT16O =    11;
-enum R_68K_GOT8O =     12;
-enum R_68K_PLT32 =     13;
-enum R_68K_PLT16 =     14;
-enum R_68K_PLT8 =      15;
-enum R_68K_PLT32O =    16;
-enum R_68K_PLT16O =    17;
-enum R_68K_PLT8O =     18;
-enum R_68K_COPY =      19;
-enum R_68K_GLOB_DAT =  20;
-enum R_68K_JMP_SLOT =  21;
-enum R_68K_RELATIVE =  22;
-enum R_68K_TLS_GD32 =      25;
-enum R_68K_TLS_GD16 =      26;
-enum R_68K_TLS_GD8 =       27;
-enum R_68K_TLS_LDM32 =     28;
-enum R_68K_TLS_LDM16 =     29;
-enum R_68K_TLS_LDM8 =      30;
-enum R_68K_TLS_LDO32 =     31;
-enum R_68K_TLS_LDO16 =     32;
-enum R_68K_TLS_LDO8 =      33;
-enum R_68K_TLS_IE32 =      34;
-enum R_68K_TLS_IE16 =      35;
-enum R_68K_TLS_IE8 =       36;
-enum R_68K_TLS_LE32 =      37;
-enum R_68K_TLS_LE16 =      38;
-enum R_68K_TLS_LE8 =       39;
-enum R_68K_TLS_DTPMOD32 =  40;
-enum R_68K_TLS_DTPREL32 =  41;
-enum R_68K_TLS_TPREL32 =   42;
-enum R_68K_NUM =       43;
-
-enum R_386_NONE =         0;
-enum R_386_32 =           1;
-enum R_386_PC32 =         2;
-enum R_386_GOT32 =        3;
-enum R_386_PLT32 =        4;
-enum R_386_COPY =         5;
-enum R_386_GLOB_DAT =     6;
-enum R_386_JMP_SLOT =     7;
-enum R_386_RELATIVE =     8;
-enum R_386_GOTOFF =       9;
-enum R_386_GOTPC =        10;
-enum R_386_32PLT =        11;
-enum R_386_TLS_TPOFF =    14;
-enum R_386_TLS_IE =       15;
-enum R_386_TLS_GOTIE =    16;
-enum R_386_TLS_LE =       17;
-enum R_386_TLS_GD =       18;
-enum R_386_TLS_LDM =      19;
-enum R_386_16 =           20;
-enum R_386_PC16 =         21;
-enum R_386_8 =            22;
-enum R_386_PC8 =          23;
-enum R_386_TLS_GD_32 =    24;
-enum R_386_TLS_GD_PUSH =  25;
-enum R_386_TLS_GD_CALL =  26;
-enum R_386_TLS_GD_POP =   27;
-enum R_386_TLS_LDM_32 =   28;
-enum R_386_TLS_LDM_PUSH = 29;
-enum R_386_TLS_LDM_CALL = 30;
-enum R_386_TLS_LDM_POP =  31;
-enum R_386_TLS_LDO_32 =   32;
-enum R_386_TLS_IE_32 =    33;
-enum R_386_TLS_LE_32 =    34;
-enum R_386_TLS_DTPMOD32 = 35;
-enum R_386_TLS_DTPOFF32 = 36;
-enum R_386_TLS_TPOFF32 =  37;
-enum R_386_SIZE32 =       38;
-enum R_386_TLS_GOTDESC =  39;
-enum R_386_TLS_DESC_CALL = 40;
-enum R_386_TLS_DESC =     41;
-enum R_386_IRELATIVE =    42;
-enum R_386_NUM =          43;
-
-enum STT_SPARC_REGISTER =      13;
-
-enum EF_SPARCV9_MM =           3;
-enum EF_SPARCV9_TSO =          0;
-enum EF_SPARCV9_PSO =          1;
-enum EF_SPARCV9_RMO =          2;
-enum EF_SPARC_LEDATA =         0x800000;
-enum EF_SPARC_EXT_MASK =       0xFFFF00;
-enum EF_SPARC_32PLUS =         0x000100;
-enum EF_SPARC_SUN_US1 =        0x000200;
-enum EF_SPARC_HAL_R1 =         0x000400;
-enum EF_SPARC_SUN_US3 =        0x000800;
-
-enum R_SPARC_NONE =            0;
-enum R_SPARC_8 =               1;
-enum R_SPARC_16 =              2;
-enum R_SPARC_32 =              3;
-enum R_SPARC_DISP8 =           4;
-enum R_SPARC_DISP16 =          5;
-enum R_SPARC_DISP32 =          6;
-enum R_SPARC_WDISP30 =         7;
-enum R_SPARC_WDISP22 =         8;
-enum R_SPARC_HI22 =            9;
-enum R_SPARC_22 =              10;
-enum R_SPARC_13 =              11;
-enum R_SPARC_LO10 =            12;
-enum R_SPARC_GOT10 =           13;
-enum R_SPARC_GOT13 =           14;
-enum R_SPARC_GOT22 =           15;
-enum R_SPARC_PC10 =            16;
-enum R_SPARC_PC22 =            17;
-enum R_SPARC_WPLT30 =          18;
-enum R_SPARC_COPY =            19;
-enum R_SPARC_GLOB_DAT =        20;
-enum R_SPARC_JMP_SLOT =        21;
-enum R_SPARC_RELATIVE =        22;
-enum R_SPARC_UA32 =            23;
-
-enum R_SPARC_PLT32 =           24;
-enum R_SPARC_HIPLT22 =         25;
-enum R_SPARC_LOPLT10 =         26;
-enum R_SPARC_PCPLT32 =         27;
-enum R_SPARC_PCPLT22 =         28;
-enum R_SPARC_PCPLT10 =         29;
-enum R_SPARC_10 =              30;
-enum R_SPARC_11 =              31;
-enum R_SPARC_64 =              32;
-enum R_SPARC_OLO10 =           33;
-enum R_SPARC_HH22 =            34;
-enum R_SPARC_HM10 =            35;
-enum R_SPARC_LM22 =            36;
-enum R_SPARC_PC_HH22 =         37;
-enum R_SPARC_PC_HM10 =         38;
-enum R_SPARC_PC_LM22 =         39;
-enum R_SPARC_WDISP16 =         40;
-enum R_SPARC_WDISP19 =         41;
-enum R_SPARC_GLOB_JMP =        42;
-enum R_SPARC_7 =               43;
-enum R_SPARC_5 =               44;
-enum R_SPARC_6 =               45;
-enum R_SPARC_DISP64 =          46;
-enum R_SPARC_PLT64 =           47;
-enum R_SPARC_HIX22 =           48;
-enum R_SPARC_LOX10 =           49;
-enum R_SPARC_H44 =             50;
-enum R_SPARC_M44 =             51;
-enum R_SPARC_L44 =             52;
-enum R_SPARC_REGISTER =        53;
-enum R_SPARC_UA64 =            54;
-enum R_SPARC_UA16 =            55;
-enum R_SPARC_TLS_GD_HI22 =     56;
-enum R_SPARC_TLS_GD_LO10 =     57;
-enum R_SPARC_TLS_GD_ADD =      58;
-enum R_SPARC_TLS_GD_CALL =     59;
-enum R_SPARC_TLS_LDM_HI22 =    60;
-enum R_SPARC_TLS_LDM_LO10 =    61;
-enum R_SPARC_TLS_LDM_ADD =     62;
-enum R_SPARC_TLS_LDM_CALL =    63;
-enum R_SPARC_TLS_LDO_HIX22 =   64;
-enum R_SPARC_TLS_LDO_LOX10 =   65;
-enum R_SPARC_TLS_LDO_ADD =     66;
-enum R_SPARC_TLS_IE_HI22 =     67;
-enum R_SPARC_TLS_IE_LO10 =     68;
-enum R_SPARC_TLS_IE_LD =       69;
-enum R_SPARC_TLS_IE_LDX =      70;
-enum R_SPARC_TLS_IE_ADD =      71;
-enum R_SPARC_TLS_LE_HIX22 =    72;
-enum R_SPARC_TLS_LE_LOX10 =    73;
-enum R_SPARC_TLS_DTPMOD32 =    74;
-enum R_SPARC_TLS_DTPMOD64 =    75;
-enum R_SPARC_TLS_DTPOFF32 =    76;
-enum R_SPARC_TLS_DTPOFF64 =    77;
-enum R_SPARC_TLS_TPOFF32 =     78;
-enum R_SPARC_TLS_TPOFF64 =     79;
-enum R_SPARC_GOTDATA_HIX22 =   80;
-enum R_SPARC_GOTDATA_LOX10 =   81;
-enum R_SPARC_GOTDATA_OP_HIX22 =        82;
-enum R_SPARC_GOTDATA_OP_LOX10 =        83;
-enum R_SPARC_GOTDATA_OP =      84;
-enum R_SPARC_H34 =             85;
-enum R_SPARC_SIZE32 =          86;
-enum R_SPARC_SIZE64 =          87;
-enum R_SPARC_WDISP10 =         88;
-enum R_SPARC_JMP_IREL =        248;
-enum R_SPARC_IRELATIVE =       249;
-enum R_SPARC_GNU_VTINHERIT =   250;
-enum R_SPARC_GNU_VTENTRY =     251;
-enum R_SPARC_REV32 =           252;
-enum R_SPARC_NUM =             253;
-
-enum DT_SPARC_REGISTER =       0x70000001;
-enum DT_SPARC_NUM =            2;
-
-enum EF_MIPS_NOREORDER =       1;
-enum EF_MIPS_PIC =             2;
-enum EF_MIPS_CPIC =            4;
-enum EF_MIPS_XGOT =            8;
-enum EF_MIPS_64BIT_WHIRL =     16;
-enum EF_MIPS_ABI2 =            32;
-enum EF_MIPS_ABI_ON32 =        64;
-enum EF_MIPS_ARCH =            0xf0000000;
-
-enum EF_MIPS_ARCH_1 =          0x00000000;
-enum EF_MIPS_ARCH_2 =          0x10000000;
-enum EF_MIPS_ARCH_3 =          0x20000000;
-enum EF_MIPS_ARCH_4 =          0x30000000;
-enum EF_MIPS_ARCH_5 =          0x40000000;
-enum EF_MIPS_ARCH_32 =         0x50000000;
-enum EF_MIPS_ARCH_64 =         0x60000000;
-enum EF_MIPS_ARCH_32R2 =       0x70000000;
-enum EF_MIPS_ARCH_64R2 =       0x80000000;
-
-enum E_MIPS_ARCH_1 =           EF_MIPS_ARCH_1;
-enum E_MIPS_ARCH_2 =           EF_MIPS_ARCH_2;
-enum E_MIPS_ARCH_3 =           EF_MIPS_ARCH_3;
-enum E_MIPS_ARCH_4 =           EF_MIPS_ARCH_4;
-enum E_MIPS_ARCH_5 =           EF_MIPS_ARCH_5;
-enum E_MIPS_ARCH_32 =          EF_MIPS_ARCH_32;
-enum E_MIPS_ARCH_64 =          EF_MIPS_ARCH_64;
-
-enum SHN_MIPS_ACOMMON =        0xff00;
-enum SHN_MIPS_TEXT =           0xff01;
-enum SHN_MIPS_DATA =           0xff02;
-enum SHN_MIPS_SCOMMON =        0xff03;
-enum SHN_MIPS_SUNDEFINED =     0xff04;
-
-enum SHT_MIPS_LIBLIST =        0x70000000;
-enum SHT_MIPS_MSYM =           0x70000001;
-enum SHT_MIPS_CONFLICT =       0x70000002;
-enum SHT_MIPS_GPTAB =          0x70000003;
-enum SHT_MIPS_UCODE =          0x70000004;
-enum SHT_MIPS_DEBUG =          0x70000005;
-enum SHT_MIPS_REGINFO =        0x70000006;
-enum SHT_MIPS_PACKAGE =        0x70000007;
-enum SHT_MIPS_PACKSYM =        0x70000008;
-enum SHT_MIPS_RELD =           0x70000009;
-enum SHT_MIPS_IFACE =          0x7000000b;
-enum SHT_MIPS_CONTENT =        0x7000000c;
-enum SHT_MIPS_OPTIONS =        0x7000000d;
-enum SHT_MIPS_SHDR =           0x70000010;
-enum SHT_MIPS_FDESC =          0x70000011;
-enum SHT_MIPS_EXTSYM =         0x70000012;
-enum SHT_MIPS_DENSE =          0x70000013;
-enum SHT_MIPS_PDESC =          0x70000014;
-enum SHT_MIPS_LOCSYM =         0x70000015;
-enum SHT_MIPS_AUXSYM =         0x70000016;
-enum SHT_MIPS_OPTSYM =         0x70000017;
-enum SHT_MIPS_LOCSTR =         0x70000018;
-enum SHT_MIPS_LINE =           0x70000019;
-enum SHT_MIPS_RFDESC =         0x7000001a;
-enum SHT_MIPS_DELTASYM =       0x7000001b;
-enum SHT_MIPS_DELTAINST =      0x7000001c;
-enum SHT_MIPS_DELTACLASS =     0x7000001d;
-enum SHT_MIPS_DWARF =          0x7000001e;
-enum SHT_MIPS_DELTADECL =      0x7000001f;
-enum SHT_MIPS_SYMBOL_LIB =     0x70000020;
-enum SHT_MIPS_EVENTS =         0x70000021;
-enum SHT_MIPS_TRANSLATE =      0x70000022;
-enum SHT_MIPS_PIXIE =          0x70000023;
-enum SHT_MIPS_XLATE =          0x70000024;
-enum SHT_MIPS_XLATE_DEBUG =    0x70000025;
-enum SHT_MIPS_WHIRL =          0x70000026;
-enum SHT_MIPS_EH_REGION =      0x70000027;
-enum SHT_MIPS_XLATE_OLD =      0x70000028;
-enum SHT_MIPS_PDR_EXCEPTION =  0x70000029;
-
-enum SHF_MIPS_GPREL =          0x10000000;
-enum SHF_MIPS_MERGE =          0x20000000;
-enum SHF_MIPS_ADDR =           0x40000000;
-enum SHF_MIPS_STRINGS =        0x80000000;
-enum SHF_MIPS_NOSTRIP =        0x08000000;
-enum SHF_MIPS_LOCAL =          0x04000000;
-enum SHF_MIPS_NAMES =          0x02000000;
-enum SHF_MIPS_NODUPE =         0x01000000;
-enum STO_MIPS_DEFAULT =                0x0;
-enum STO_MIPS_INTERNAL =               0x1;
-enum STO_MIPS_HIDDEN =                 0x2;
-enum STO_MIPS_PROTECTED =              0x3;
-enum STO_MIPS_PLT =                    0x8;
-enum STO_MIPS_SC_ALIGN_UNUSED =        0xff;
-enum STB_MIPS_SPLIT_COMMON =           13;
-
-union Elf32_gptab
-{
-    struct _gt_header
-    {
-        Elf32_Word gt_current_g_value;
-        Elf32_Word gt_unused;
-    } _gt_header gt_header;
-    struct _gt_entry
-    {
-        Elf32_Word gt_g_value;
-        Elf32_Word gt_bytes;
-    } _gt_entry gt_entry;
-}
-
-struct Elf32_RegInfo
-{
-    Elf32_Word ri_gprmask;
-    Elf32_Word[4] ri_cprmask;
-    Elf32_Sword ri_gp_value;
-}
-
-struct Elf_Options
-{
-    ubyte kind;
-    ubyte size;
-    Elf32_Section section;
-    Elf32_Word info;
-}
-
-enum ODK_NULL =        0;
-enum ODK_REGINFO =     1;
-enum ODK_EXCEPTIONS =  2;
-enum ODK_PAD =         3;
-enum ODK_HWPATCH =     4;
-enum ODK_FILL =        5;
-enum ODK_TAGS =        6;
-enum ODK_HWAND =       7;
-enum ODK_HWOR =        8;
-
-enum OEX_FPU_MIN =     0x1f;
-enum OEX_FPU_MAX =     0x1f00;
-enum OEX_PAGE0 =       0x10000;
-enum OEX_SMM =         0x20000;
-enum OEX_FPDBUG =      0x40000;
-enum OEX_PRECISEFP =   OEX_FPDBUG;
-enum OEX_DISMISS =     0x80000;
-
-enum OEX_FPU_INVAL =   0x10;
-enum OEX_FPU_DIV0 =    0x08;
-enum OEX_FPU_OFLO =    0x04;
-enum OEX_FPU_UFLO =    0x02;
-enum OEX_FPU_INEX =    0x01;
-
-enum OHW_R4KEOP =      0x1;
-enum OHW_R8KPFETCH =   0x2;
-enum OHW_R5KEOP =      0x4;
-enum OHW_R5KCVTL =     0x8;
-
-enum OPAD_PREFIX =     0x1;
-enum OPAD_POSTFIX =    0x2;
-enum OPAD_SYMBOL =     0x4;
-
-struct Elf_Options_Hw
-{
-    Elf32_Word hwp_flags1;
-    Elf32_Word hwp_flags2;
-}
-
-enum OHWA0_R4KEOP_CHECKED =    0x00000001;
-enum OHWA1_R4KEOP_CLEAN =      0x00000002;
-
-enum R_MIPS_NONE =             0;
-enum R_MIPS_16 =               1;
-enum R_MIPS_32 =               2;
-enum R_MIPS_REL32 =            3;
-enum R_MIPS_26 =               4;
-enum R_MIPS_HI16 =             5;
-enum R_MIPS_LO16 =             6;
-enum R_MIPS_GPREL16 =          7;
-enum R_MIPS_LITERAL =          8;
-enum R_MIPS_GOT16 =            9;
-enum R_MIPS_PC16 =             10;
-enum R_MIPS_CALL16 =           11;
-enum R_MIPS_GPREL32 =          12;
-
-enum R_MIPS_SHIFT5 =           16;
-enum R_MIPS_SHIFT6 =           17;
-enum R_MIPS_64 =               18;
-enum R_MIPS_GOT_DISP =         19;
-enum R_MIPS_GOT_PAGE =         20;
-enum R_MIPS_GOT_OFST =         21;
-enum R_MIPS_GOT_HI16 =         22;
-enum R_MIPS_GOT_LO16 =         23;
-enum R_MIPS_SUB =              24;
-enum R_MIPS_INSERT_A =         25;
-enum R_MIPS_INSERT_B =         26;
-enum R_MIPS_DELETE =           27;
-enum R_MIPS_HIGHER =           28;
-enum R_MIPS_HIGHEST =          29;
-enum R_MIPS_CALL_HI16 =        30;
-enum R_MIPS_CALL_LO16 =        31;
-enum R_MIPS_SCN_DISP =         32;
-enum R_MIPS_REL16 =            33;
-enum R_MIPS_ADD_IMMEDIATE =    34;
-enum R_MIPS_PJUMP =            35;
-enum R_MIPS_RELGOT =           36;
-enum R_MIPS_JALR =             37;
-enum R_MIPS_TLS_DTPMOD32 =     38;
-enum R_MIPS_TLS_DTPREL32 =     39;
-enum R_MIPS_TLS_DTPMOD64 =     40;
-enum R_MIPS_TLS_DTPREL64 =     41;
-enum R_MIPS_TLS_GD =           42;
-enum R_MIPS_TLS_LDM =          43;
-enum R_MIPS_TLS_DTPREL_HI16 =  44;
-enum R_MIPS_TLS_DTPREL_LO16 =  45;
-enum R_MIPS_TLS_GOTTPREL =     46;
-enum R_MIPS_TLS_TPREL32 =      47;
-enum R_MIPS_TLS_TPREL64 =      48;
-enum R_MIPS_TLS_TPREL_HI16 =   49;
-enum R_MIPS_TLS_TPREL_LO16 =   50;
-enum R_MIPS_GLOB_DAT =         51;
-enum R_MIPS_COPY =             126;
-enum R_MIPS_JUMP_SLOT =        127;
-enum R_MIPS_NUM =              128;
-
-enum PT_MIPS_REGINFO = 0x70000000;
-enum PT_MIPS_RTPROC =  0x70000001;
-enum PT_MIPS_OPTIONS = 0x70000002;
-
-enum PF_MIPS_LOCAL =   0x10000000;
-
-enum DT_MIPS_RLD_VERSION =  0x70000001;
-enum DT_MIPS_TIME_STAMP =   0x70000002;
-enum DT_MIPS_ICHECKSUM =    0x70000003;
-enum DT_MIPS_IVERSION =     0x70000004;
-enum DT_MIPS_FLAGS =        0x70000005;
-enum DT_MIPS_BASE_ADDRESS = 0x70000006;
-enum DT_MIPS_MSYM =         0x70000007;
-enum DT_MIPS_CONFLICT =     0x70000008;
-enum DT_MIPS_LIBLIST =      0x70000009;
-enum DT_MIPS_LOCAL_GOTNO =  0x7000000a;
-enum DT_MIPS_CONFLICTNO =   0x7000000b;
-enum DT_MIPS_LIBLISTNO =    0x70000010;
-enum DT_MIPS_SYMTABNO =     0x70000011;
-enum DT_MIPS_UNREFEXTNO =   0x70000012;
-enum DT_MIPS_GOTSYM =       0x70000013;
-enum DT_MIPS_HIPAGENO =     0x70000014;
-enum DT_MIPS_RLD_MAP =      0x70000016;
-enum DT_MIPS_DELTA_CLASS =  0x70000017;
-enum DT_MIPS_DELTA_CLASS_NO =    0x70000018;
-enum DT_MIPS_DELTA_INSTANCE =    0x70000019;
-enum DT_MIPS_DELTA_INSTANCE_NO = 0x7000001a;
-enum DT_MIPS_DELTA_RELOC =  0x7000001b;
-enum DT_MIPS_DELTA_RELOC_NO = 0x7000001c;
-enum DT_MIPS_DELTA_SYM =    0x7000001d;
-enum DT_MIPS_DELTA_SYM_NO = 0x7000001e;
-enum DT_MIPS_DELTA_CLASSSYM = 0x70000020;
-enum DT_MIPS_DELTA_CLASSSYM_NO = 0x70000021;
-enum DT_MIPS_CXX_FLAGS =    0x70000022;
-enum DT_MIPS_PIXIE_INIT =   0x70000023;
-enum DT_MIPS_SYMBOL_LIB =   0x70000024;
-enum DT_MIPS_LOCALPAGE_GOTIDX = 0x70000025;
-enum DT_MIPS_LOCAL_GOTIDX = 0x70000026;
-enum DT_MIPS_HIDDEN_GOTIDX = 0x70000027;
-enum DT_MIPS_PROTECTED_GOTIDX = 0x70000028;
-enum DT_MIPS_OPTIONS =      0x70000029;
-enum DT_MIPS_INTERFACE =    0x7000002a;
-enum DT_MIPS_DYNSTR_ALIGN = 0x7000002b;
-enum DT_MIPS_INTERFACE_SIZE = 0x7000002c;
-enum DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 0x7000002d;
-enum DT_MIPS_PERF_SUFFIX =  0x7000002e;
-enum DT_MIPS_COMPACT_SIZE = 0x7000002f;
-enum DT_MIPS_GP_VALUE =     0x70000030;
-enum DT_MIPS_AUX_DYNAMIC =  0x70000031;
-enum DT_MIPS_PLTGOT =       0x70000032;
-enum DT_MIPS_RWPLT =        0x70000034;
-enum DT_MIPS_NUM =          0x35;
-
-enum RHF_NONE =                   0;
-enum RHF_QUICKSTART =             (1 << 0);
-enum RHF_NOTPOT =                 (1 << 1);
-enum RHF_NO_LIBRARY_REPLACEMENT = (1 << 2);
-enum RHF_NO_MOVE =                (1 << 3);
-enum RHF_SGI_ONLY =               (1 << 4);
-enum RHF_GUARANTEE_INIT =         (1 << 5);
-enum RHF_DELTA_C_PLUS_PLUS =      (1 << 6);
-enum RHF_GUARANTEE_START_INIT =   (1 << 7);
-enum RHF_PIXIE =                  (1 << 8);
-enum RHF_DEFAULT_DELAY_LOAD =     (1 << 9);
-enum RHF_REQUICKSTART =           (1 << 10);
-enum RHF_REQUICKSTARTED =         (1 << 11);
-enum RHF_CORD =                   (1 << 12);
-enum RHF_NO_UNRES_UNDEF =         (1 << 13);
-enum RHF_RLD_ORDER_SAFE =         (1 << 14);
-
-struct Elf32_Lib
-{
-    Elf32_Word l_name;
-    Elf32_Word l_time_stamp;
-    Elf32_Word l_checksum;
-    Elf32_Word l_version;
-    Elf32_Word l_flags;
-}
-
-struct Elf64_Lib
-{
-    Elf64_Word l_name;
-    Elf64_Word l_time_stamp;
-    Elf64_Word l_checksum;
-    Elf64_Word l_version;
-    Elf64_Word l_flags;
-}
-
-enum LL_NONE =           0;
-enum LL_EXACT_MATCH =    (1 << 0);
-enum LL_IGNORE_INT_VER = (1 << 1);
-enum LL_REQUIRE_MINOR =  (1 << 2);
-enum LL_EXPORTS =        (1 << 3);
-enum LL_DELAY_LOAD =     (1 << 4);
-enum LL_DELTA =          (1 << 5);
-
-alias Elf32_Addr Elf32_Conflict;
-
-enum EF_PARISC_TRAPNIL =       0x00010000;
-enum EF_PARISC_EXT =           0x00020000;
-enum EF_PARISC_LSB =           0x00040000;
-enum EF_PARISC_WIDE =          0x00080000;
-enum EF_PARISC_NO_KABP =       0x00100000;
-enum EF_PARISC_LAZYSWAP =      0x00400000;
-enum EF_PARISC_ARCH =          0x0000ffff;
-
-enum EFA_PARISC_1_0 =              0x020b;
-enum EFA_PARISC_1_1 =              0x0210;
-enum EFA_PARISC_2_0 =              0x0214;
-
-enum SHN_PARISC_ANSI_COMMON =  0xff00;
-enum SHN_PARISC_HUGE_COMMON =  0xff01;
-
-enum SHT_PARISC_EXT =          0x70000000;
-enum SHT_PARISC_UNWIND =       0x70000001;
-enum SHT_PARISC_DOC =          0x70000002;
-
-enum SHF_PARISC_SHORT =        0x20000000;
-enum SHF_PARISC_HUGE =         0x40000000;
-enum SHF_PARISC_SBP =          0x80000000;
-
-enum STT_PARISC_MILLICODE =    13;
-
-enum STT_HP_OPAQUE =           (STT_LOOS + 0x1);
-enum STT_HP_STUB =             (STT_LOOS + 0x2);
-
-enum R_PARISC_NONE =           0;
-enum R_PARISC_DIR32 =          1;
-enum R_PARISC_DIR21L =         2;
-enum R_PARISC_DIR17R =         3;
-enum R_PARISC_DIR17F =         4;
-enum R_PARISC_DIR14R =         6;
-enum R_PARISC_PCREL32 =        9;
-enum R_PARISC_PCREL21L =       10;
-enum R_PARISC_PCREL17R =       11;
-enum R_PARISC_PCREL17F =       12;
-enum R_PARISC_PCREL14R =       14;
-enum R_PARISC_DPREL21L =       18;
-enum R_PARISC_DPREL14R =       22;
-enum R_PARISC_GPREL21L =       26;
-enum R_PARISC_GPREL14R =       30;
-enum R_PARISC_LTOFF21L =       34;
-enum R_PARISC_LTOFF14R =       38;
-enum R_PARISC_SECREL32 =       41;
-enum R_PARISC_SEGBASE =        48;
-enum R_PARISC_SEGREL32 =       49;
-enum R_PARISC_PLTOFF21L =      50;
-enum R_PARISC_PLTOFF14R =      54;
-enum R_PARISC_LTOFF_FPTR32 =   57;
-enum R_PARISC_LTOFF_FPTR21L =  58;
-enum R_PARISC_LTOFF_FPTR14R =  62;
-enum R_PARISC_FPTR64 =         64;
-enum R_PARISC_PLABEL32 =       65;
-enum R_PARISC_PLABEL21L =      66;
-enum R_PARISC_PLABEL14R =      70;
-enum R_PARISC_PCREL64 =        72;
-enum R_PARISC_PCREL22F =       74;
-enum R_PARISC_PCREL14WR =      75;
-enum R_PARISC_PCREL14DR =      76;
-enum R_PARISC_PCREL16F =       77;
-enum R_PARISC_PCREL16WF =      78;
-enum R_PARISC_PCREL16DF =      79;
-enum R_PARISC_DIR64 =          80;
-enum R_PARISC_DIR14WR =        83;
-enum R_PARISC_DIR14DR =        84;
-enum R_PARISC_DIR16F =         85;
-enum R_PARISC_DIR16WF =        86;
-enum R_PARISC_DIR16DF =        87;
-enum R_PARISC_GPREL64 =        88;
-enum R_PARISC_GPREL14WR =      91;
-enum R_PARISC_GPREL14DR =      92;
-enum R_PARISC_GPREL16F =       93;
-enum R_PARISC_GPREL16WF =      94;
-enum R_PARISC_GPREL16DF =      95;
-enum R_PARISC_LTOFF64 =        96;
-enum R_PARISC_LTOFF14WR =      99;
-enum R_PARISC_LTOFF14DR =      100;
-enum R_PARISC_LTOFF16F =       101;
-enum R_PARISC_LTOFF16WF =      102;
-enum R_PARISC_LTOFF16DF =      103;
-enum R_PARISC_SECREL64 =       104;
-enum R_PARISC_SEGREL64 =       112;
-enum R_PARISC_PLTOFF14WR =     115;
-enum R_PARISC_PLTOFF14DR =     116;
-enum R_PARISC_PLTOFF16F =      117;
-enum R_PARISC_PLTOFF16WF =     118;
-enum R_PARISC_PLTOFF16DF =     119;
-enum R_PARISC_LTOFF_FPTR64 =   120;
-enum R_PARISC_LTOFF_FPTR14WR = 123;
-enum R_PARISC_LTOFF_FPTR14DR = 124;
-enum R_PARISC_LTOFF_FPTR16F =  125;
-enum R_PARISC_LTOFF_FPTR16WF = 126;
-enum R_PARISC_LTOFF_FPTR16DF = 127;
-enum R_PARISC_LORESERVE =      128;
-enum R_PARISC_COPY =           128;
-enum R_PARISC_IPLT =           129;
-enum R_PARISC_EPLT =           130;
-enum R_PARISC_TPREL32 =        153;
-enum R_PARISC_TPREL21L =       154;
-enum R_PARISC_TPREL14R =       158;
-enum R_PARISC_LTOFF_TP21L =    162;
-enum R_PARISC_LTOFF_TP14R =    166;
-enum R_PARISC_LTOFF_TP14F =    167;
-enum R_PARISC_TPREL64 =        216;
-enum R_PARISC_TPREL14WR =      219;
-enum R_PARISC_TPREL14DR =      220;
-enum R_PARISC_TPREL16F =       221;
-enum R_PARISC_TPREL16WF =      222;
-enum R_PARISC_TPREL16DF =      223;
-enum R_PARISC_LTOFF_TP64 =     224;
-enum R_PARISC_LTOFF_TP14WR =   227;
-enum R_PARISC_LTOFF_TP14DR =   228;
-enum R_PARISC_LTOFF_TP16F =    229;
-enum R_PARISC_LTOFF_TP16WF =   230;
-enum R_PARISC_LTOFF_TP16DF =   231;
-enum R_PARISC_GNU_VTENTRY =    232;
-enum R_PARISC_GNU_VTINHERIT =  233;
-enum R_PARISC_TLS_GD21L =      234;
-enum R_PARISC_TLS_GD14R =      235;
-enum R_PARISC_TLS_GDCALL =     236;
-enum R_PARISC_TLS_LDM21L =     237;
-enum R_PARISC_TLS_LDM14R =     238;
-enum R_PARISC_TLS_LDMCALL =    239;
-enum R_PARISC_TLS_LDO21L =     240;
-enum R_PARISC_TLS_LDO14R =     241;
-enum R_PARISC_TLS_DTPMOD32 =   242;
-enum R_PARISC_TLS_DTPMOD64 =   243;
-enum R_PARISC_TLS_DTPOFF32 =   244;
-enum R_PARISC_TLS_DTPOFF64 =   245;
-enum R_PARISC_TLS_LE21L =      R_PARISC_TPREL21L;
-enum R_PARISC_TLS_LE14R =      R_PARISC_TPREL14R;
-enum R_PARISC_TLS_IE21L =      R_PARISC_LTOFF_TP21L;
-enum R_PARISC_TLS_IE14R =      R_PARISC_LTOFF_TP14R;
-enum R_PARISC_TLS_TPREL32 =    R_PARISC_TPREL32;
-enum R_PARISC_TLS_TPREL64 =    R_PARISC_TPREL64;
-enum R_PARISC_HIRESERVE =      255;
-
-enum PT_HP_TLS =               (PT_LOOS + 0x0);
-enum PT_HP_CORE_NONE =         (PT_LOOS + 0x1);
-enum PT_HP_CORE_VERSION =      (PT_LOOS + 0x2);
-enum PT_HP_CORE_KERNEL =       (PT_LOOS + 0x3);
-enum PT_HP_CORE_COMM =         (PT_LOOS + 0x4);
-enum PT_HP_CORE_PROC =         (PT_LOOS + 0x5);
-enum PT_HP_CORE_LOADABLE =     (PT_LOOS + 0x6);
-enum PT_HP_CORE_STACK =        (PT_LOOS + 0x7);
-enum PT_HP_CORE_SHM =          (PT_LOOS + 0x8);
-enum PT_HP_CORE_MMF =          (PT_LOOS + 0x9);
-enum PT_HP_PARALLEL =          (PT_LOOS + 0x10);
-enum PT_HP_FASTBIND =          (PT_LOOS + 0x11);
-enum PT_HP_OPT_ANNOT =         (PT_LOOS + 0x12);
-enum PT_HP_HSL_ANNOT =         (PT_LOOS + 0x13);
-enum PT_HP_STACK =             (PT_LOOS + 0x14);
-
-enum PT_PARISC_ARCHEXT =       0x70000000;
-enum PT_PARISC_UNWIND =        0x70000001;
-
-enum PF_PARISC_SBP =           0x08000000;
-
-enum PF_HP_PAGE_SIZE =         0x00100000;
-enum PF_HP_FAR_SHARED =        0x00200000;
-enum PF_HP_NEAR_SHARED =       0x00400000;
-enum PF_HP_CODE =              0x01000000;
-enum PF_HP_MODIFY =            0x02000000;
-enum PF_HP_LAZYSWAP =          0x04000000;
-enum PF_HP_SBP =               0x08000000;
-
-enum EF_ALPHA_32BIT =          1;
-enum EF_ALPHA_CANRELAX =       2;
-enum SHT_ALPHA_DEBUG =         0x70000001;
-enum SHT_ALPHA_REGINFO =       0x70000002;
-
-enum SHF_ALPHA_GPREL =         0x10000000;
-enum STO_ALPHA_NOPV =          0x80;
-enum STO_ALPHA_STD_GPLOAD =    0x88;
-
-enum R_ALPHA_NONE =            0;
-enum R_ALPHA_REFLONG =         1;
-enum R_ALPHA_REFQUAD =         2;
-enum R_ALPHA_GPREL32 =         3;
-enum R_ALPHA_LITERAL =         4;
-enum R_ALPHA_LITUSE =          5;
-enum R_ALPHA_GPDISP =          6;
-enum R_ALPHA_BRADDR =          7;
-enum R_ALPHA_HINT =            8;
-enum R_ALPHA_SREL16 =          9;
-enum R_ALPHA_SREL32 =          10;
-enum R_ALPHA_SREL64 =          11;
-enum R_ALPHA_GPRELHIGH =       17;
-enum R_ALPHA_GPRELLOW =        18;
-enum R_ALPHA_GPREL16 =         19;
-enum R_ALPHA_COPY =            24;
-enum R_ALPHA_GLOB_DAT =        25;
-enum R_ALPHA_JMP_SLOT =        26;
-enum R_ALPHA_RELATIVE =        27;
-enum R_ALPHA_TLS_GD_HI =       28;
-enum R_ALPHA_TLSGD =           29;
-enum R_ALPHA_TLS_LDM =         30;
-enum R_ALPHA_DTPMOD64 =        31;
-enum R_ALPHA_GOTDTPREL =       32;
-enum R_ALPHA_DTPREL64 =        33;
-enum R_ALPHA_DTPRELHI =        34;
-enum R_ALPHA_DTPRELLO =        35;
-enum R_ALPHA_DTPREL16 =        36;
-enum R_ALPHA_GOTTPREL =        37;
-enum R_ALPHA_TPREL64 =         38;
-enum R_ALPHA_TPRELHI =         39;
-enum R_ALPHA_TPRELLO =         40;
-enum R_ALPHA_TPREL16 =         41;
-enum R_ALPHA_NUM =             46;
-enum LITUSE_ALPHA_ADDR =       0;
-enum LITUSE_ALPHA_BASE =       1;
-enum LITUSE_ALPHA_BYTOFF =     2;
-enum LITUSE_ALPHA_JSR =        3;
-enum LITUSE_ALPHA_TLS_GD =     4;
-enum LITUSE_ALPHA_TLS_LDM =    5;
-enum DT_ALPHA_PLTRO =          (DT_LOPROC + 0);
-enum DT_ALPHA_NUM =            1;
-enum EF_PPC_EMB =              0x80000000;
-enum EF_PPC_RELOCATABLE =      0x00010000;
-enum EF_PPC_RELOCATABLE_LIB =  0x00008000;
-enum R_PPC_NONE =              0;
-enum R_PPC_ADDR32 =            1;
-enum R_PPC_ADDR24 =            2;
-enum R_PPC_ADDR16 =            3;
-enum R_PPC_ADDR16_LO =         4;
-enum R_PPC_ADDR16_HI =         5;
-enum R_PPC_ADDR16_HA =         6;
-enum R_PPC_ADDR14 =            7;
-enum R_PPC_ADDR14_BRTAKEN =    8;
-enum R_PPC_ADDR14_BRNTAKEN =   9;
-enum R_PPC_REL24 =             10;
-enum R_PPC_REL14 =             11;
-enum R_PPC_REL14_BRTAKEN =     12;
-enum R_PPC_REL14_BRNTAKEN =    13;
-enum R_PPC_GOT16 =             14;
-enum R_PPC_GOT16_LO =          15;
-enum R_PPC_GOT16_HI =          16;
-enum R_PPC_GOT16_HA =          17;
-enum R_PPC_PLTREL24 =          18;
-enum R_PPC_COPY =              19;
-enum R_PPC_GLOB_DAT =          20;
-enum R_PPC_JMP_SLOT =          21;
-enum R_PPC_RELATIVE =          22;
-enum R_PPC_LOCAL24PC =         23;
-enum R_PPC_UADDR32 =           24;
-enum R_PPC_UADDR16 =           25;
-enum R_PPC_REL32 =             26;
-enum R_PPC_PLT32 =             27;
-enum R_PPC_PLTREL32 =          28;
-enum R_PPC_PLT16_LO =          29;
-enum R_PPC_PLT16_HI =          30;
-enum R_PPC_PLT16_HA =          31;
-enum R_PPC_SDAREL16 =          32;
-enum R_PPC_SECTOFF =           33;
-enum R_PPC_SECTOFF_LO =        34;
-enum R_PPC_SECTOFF_HI =        35;
-enum R_PPC_SECTOFF_HA =        36;
-enum R_PPC_TLS =               67;
-enum R_PPC_DTPMOD32 =          68;
-enum R_PPC_TPREL16 =           69;
-enum R_PPC_TPREL16_LO =        70;
-enum R_PPC_TPREL16_HI =        71;
-enum R_PPC_TPREL16_HA =        72;
-enum R_PPC_TPREL32 =           73;
-enum R_PPC_DTPREL16 =          74;
-enum R_PPC_DTPREL16_LO =       75;
-enum R_PPC_DTPREL16_HI =       76;
-enum R_PPC_DTPREL16_HA =       77;
-enum R_PPC_DTPREL32 =          78;
-enum R_PPC_GOT_TLSGD16 =       79;
-enum R_PPC_GOT_TLSGD16_LO =    80;
-enum R_PPC_GOT_TLSGD16_HI =    81;
-enum R_PPC_GOT_TLSGD16_HA =    82;
-enum R_PPC_GOT_TLSLD16 =       83;
-enum R_PPC_GOT_TLSLD16_LO =    84;
-enum R_PPC_GOT_TLSLD16_HI =    85;
-enum R_PPC_GOT_TLSLD16_HA =    86;
-enum R_PPC_GOT_TPREL16 =       87;
-enum R_PPC_GOT_TPREL16_LO =    88;
-enum R_PPC_GOT_TPREL16_HI =    89;
-enum R_PPC_GOT_TPREL16_HA =    90;
-enum R_PPC_GOT_DTPREL16 =      91;
-enum R_PPC_GOT_DTPREL16_LO =   92;
-enum R_PPC_GOT_DTPREL16_HI =   93;
-enum R_PPC_GOT_DTPREL16_HA =   94;
-enum R_PPC_EMB_NADDR32 =       101;
-enum R_PPC_EMB_NADDR16 =       102;
-enum R_PPC_EMB_NADDR16_LO =    103;
-enum R_PPC_EMB_NADDR16_HI =    104;
-enum R_PPC_EMB_NADDR16_HA =    105;
-enum R_PPC_EMB_SDAI16 =        106;
-enum R_PPC_EMB_SDA2I16 =       107;
-enum R_PPC_EMB_SDA2REL =       108;
-enum R_PPC_EMB_SDA21 =         109;
-enum R_PPC_EMB_MRKREF =        110;
-enum R_PPC_EMB_RELSEC16 =      111;
-enum R_PPC_EMB_RELST_LO =      112;
-enum R_PPC_EMB_RELST_HI =      113;
-enum R_PPC_EMB_RELST_HA =      114;
-enum R_PPC_EMB_BIT_FLD =       115;
-enum R_PPC_EMB_RELSDA =        116;
-enum R_PPC_DIAB_SDA21_LO =     180;
-enum R_PPC_DIAB_SDA21_HI =     181;
-enum R_PPC_DIAB_SDA21_HA =     182;
-enum R_PPC_DIAB_RELSDA_LO =    183;
-enum R_PPC_DIAB_RELSDA_HI =    184;
-enum R_PPC_DIAB_RELSDA_HA =    185;
-enum R_PPC_IRELATIVE =         248;
-enum R_PPC_REL16 =             249;
-enum R_PPC_REL16_LO =          250;
-enum R_PPC_REL16_HI =          251;
-enum R_PPC_REL16_HA =          252;
-enum R_PPC_TOC16 =             255;
-enum DT_PPC_GOT =              (DT_LOPROC + 0);
-enum DT_PPC_NUM =              1;
-enum R_PPC64_NONE =            R_PPC_NONE;
-enum R_PPC64_ADDR32 =          R_PPC_ADDR32;
-enum R_PPC64_ADDR24 =          R_PPC_ADDR24;
-enum R_PPC64_ADDR16 =          R_PPC_ADDR16;
-enum R_PPC64_ADDR16_LO =       R_PPC_ADDR16_LO;
-enum R_PPC64_ADDR16_HI =       R_PPC_ADDR16_HI;
-enum R_PPC64_ADDR16_HA =       R_PPC_ADDR16_HA;
-enum R_PPC64_ADDR14 =          R_PPC_ADDR14;
-enum R_PPC64_ADDR14_BRTAKEN =  R_PPC_ADDR14_BRTAKEN;
-enum R_PPC64_ADDR14_BRNTAKEN = R_PPC_ADDR14_BRNTAKEN;
-enum R_PPC64_REL24 =           R_PPC_REL24;
-enum R_PPC64_REL14 =           R_PPC_REL14;
-enum R_PPC64_REL14_BRTAKEN =   R_PPC_REL14_BRTAKEN;
-enum R_PPC64_REL14_BRNTAKEN =  R_PPC_REL14_BRNTAKEN;
-enum R_PPC64_GOT16 =           R_PPC_GOT16;
-enum R_PPC64_GOT16_LO =        R_PPC_GOT16_LO;
-enum R_PPC64_GOT16_HI =        R_PPC_GOT16_HI;
-enum R_PPC64_GOT16_HA =        R_PPC_GOT16_HA;
-
-enum R_PPC64_COPY =            R_PPC_COPY;
-enum R_PPC64_GLOB_DAT =        R_PPC_GLOB_DAT;
-enum R_PPC64_JMP_SLOT =        R_PPC_JMP_SLOT;
-enum R_PPC64_RELATIVE =        R_PPC_RELATIVE;
-
-enum R_PPC64_UADDR32 =         R_PPC_UADDR32;
-enum R_PPC64_UADDR16 =         R_PPC_UADDR16;
-enum R_PPC64_REL32 =           R_PPC_REL32;
-enum R_PPC64_PLT32 =           R_PPC_PLT32;
-enum R_PPC64_PLTREL32 =        R_PPC_PLTREL32;
-enum R_PPC64_PLT16_LO =        R_PPC_PLT16_LO;
-enum R_PPC64_PLT16_HI =        R_PPC_PLT16_HI;
-enum R_PPC64_PLT16_HA =        R_PPC_PLT16_HA;
-
-enum R_PPC64_SECTOFF =         R_PPC_SECTOFF;
-enum R_PPC64_SECTOFF_LO =      R_PPC_SECTOFF_LO;
-enum R_PPC64_SECTOFF_HI =      R_PPC_SECTOFF_HI;
-enum R_PPC64_SECTOFF_HA =      R_PPC_SECTOFF_HA;
-enum R_PPC64_ADDR30 =          37;
-enum R_PPC64_ADDR64 =          38;
-enum R_PPC64_ADDR16_HIGHER =   39;
-enum R_PPC64_ADDR16_HIGHERA =  40;
-enum R_PPC64_ADDR16_HIGHEST =  41;
-enum R_PPC64_ADDR16_HIGHESTA = 42;
-enum R_PPC64_UADDR64 =         43;
-enum R_PPC64_REL64 =           44;
-enum R_PPC64_PLT64 =           45;
-enum R_PPC64_PLTREL64 =        46;
-enum R_PPC64_TOC16 =           47;
-enum R_PPC64_TOC16_LO =        48;
-enum R_PPC64_TOC16_HI =        49;
-enum R_PPC64_TOC16_HA =        50;
-enum R_PPC64_TOC =             51;
-enum R_PPC64_PLTGOT16 =        52;
-enum R_PPC64_PLTGOT16_LO =     53;
-enum R_PPC64_PLTGOT16_HI =     54;
-enum R_PPC64_PLTGOT16_HA =     55;
-
-enum R_PPC64_ADDR16_DS =       56;
-enum R_PPC64_ADDR16_LO_DS =    57;
-enum R_PPC64_GOT16_DS =        58;
-enum R_PPC64_GOT16_LO_DS =     59;
-enum R_PPC64_PLT16_LO_DS =     60;
-enum R_PPC64_SECTOFF_DS =      61;
-enum R_PPC64_SECTOFF_LO_DS =   62;
-enum R_PPC64_TOC16_DS =        63;
-enum R_PPC64_TOC16_LO_DS =     64;
-enum R_PPC64_PLTGOT16_DS =     65;
-enum R_PPC64_PLTGOT16_LO_DS =  66;
-enum R_PPC64_TLS =             67;
-enum R_PPC64_DTPMOD64 =        68;
-enum R_PPC64_TPREL16 =         69;
-enum R_PPC64_TPREL16_LO =      70;
-enum R_PPC64_TPREL16_HI =      71;
-enum R_PPC64_TPREL16_HA =      72;
-enum R_PPC64_TPREL64 =         73;
-enum R_PPC64_DTPREL16 =        74;
-enum R_PPC64_DTPREL16_LO =     75;
-enum R_PPC64_DTPREL16_HI =     76;
-enum R_PPC64_DTPREL16_HA =     77;
-enum R_PPC64_DTPREL64 =        78;
-enum R_PPC64_GOT_TLSGD16 =     79;
-enum R_PPC64_GOT_TLSGD16_LO =  80;
-enum R_PPC64_GOT_TLSGD16_HI =  81;
-enum R_PPC64_GOT_TLSGD16_HA =  82;
-enum R_PPC64_GOT_TLSLD16 =     83;
-enum R_PPC64_GOT_TLSLD16_LO =  84;
-enum R_PPC64_GOT_TLSLD16_HI =  85;
-enum R_PPC64_GOT_TLSLD16_HA =  86;
-enum R_PPC64_GOT_TPREL16_DS =  87;
-enum R_PPC64_GOT_TPREL16_LO_DS = 88;
-enum R_PPC64_GOT_TPREL16_HI =  89;
-enum R_PPC64_GOT_TPREL16_HA =  90;
-enum R_PPC64_GOT_DTPREL16_DS = 91;
-enum R_PPC64_GOT_DTPREL16_LO_DS = 92;
-enum R_PPC64_GOT_DTPREL16_HI = 93;
-enum R_PPC64_GOT_DTPREL16_HA = 94;
-enum R_PPC64_TPREL16_DS =      95;
-enum R_PPC64_TPREL16_LO_DS =   96;
-enum R_PPC64_TPREL16_HIGHER =  97;
-enum R_PPC64_TPREL16_HIGHERA = 98;
-enum R_PPC64_TPREL16_HIGHEST = 99;
-enum R_PPC64_TPREL16_HIGHESTA = 100;
-enum R_PPC64_DTPREL16_DS =     101;
-enum R_PPC64_DTPREL16_LO_DS =  102;
-enum R_PPC64_DTPREL16_HIGHER = 103;
-enum R_PPC64_DTPREL16_HIGHERA = 104;
-enum R_PPC64_DTPREL16_HIGHEST = 105;
-enum R_PPC64_DTPREL16_HIGHESTA = 106;
-enum R_PPC64_JMP_IREL =        247;
-enum R_PPC64_IRELATIVE =       248;
-enum R_PPC64_REL16 =           249;
-enum R_PPC64_REL16_LO =        250;
-enum R_PPC64_REL16_HI =        251;
-enum R_PPC64_REL16_HA =        252;
-enum DT_PPC64_GLINK =  (DT_LOPROC + 0);
-enum DT_PPC64_OPD =    (DT_LOPROC + 1);
-enum DT_PPC64_OPDSZ =  (DT_LOPROC + 2);
-enum DT_PPC64_NUM =    3;
-enum EF_ARM_RELEXEC =          0x01;
-enum EF_ARM_HASENTRY =         0x02;
-enum EF_ARM_INTERWORK =        0x04;
-enum EF_ARM_APCS_26 =          0x08;
-enum EF_ARM_APCS_FLOAT =       0x10;
-enum EF_ARM_PIC =              0x20;
-enum EF_ARM_ALIGN8 =           0x40;
-enum EF_ARM_NEW_ABI =          0x80;
-enum EF_ARM_OLD_ABI =          0x100;
-enum EF_ARM_SOFT_FLOAT =       0x200;
-enum EF_ARM_VFP_FLOAT =        0x400;
-enum EF_ARM_MAVERICK_FLOAT =   0x800;
-
-enum EF_ARM_ABI_FLOAT_SOFT =   0x200;
-enum EF_ARM_ABI_FLOAT_HARD =   0x400;
-enum EF_ARM_SYMSARESORTED =    0x04;
-enum EF_ARM_DYNSYMSUSESEGIDX = 0x08;
-enum EF_ARM_MAPSYMSFIRST =     0x10;
-enum EF_ARM_EABIMASK =         0XFF000000;
-enum EF_ARM_BE8 =          0x00800000;
-enum EF_ARM_LE8 =          0x00400000;
-
-extern (D) auto EF_ARM_EABI_VERSION(F)(F flags) { return flags & EF_ARM_EABIMASK; }
-enum EF_ARM_EABI_UNKNOWN =     0x00000000;
-enum EF_ARM_EABI_VER1 =        0x01000000;
-enum EF_ARM_EABI_VER2 =        0x02000000;
-enum EF_ARM_EABI_VER3 =        0x03000000;
-enum EF_ARM_EABI_VER4 =        0x04000000;
-enum EF_ARM_EABI_VER5 =        0x05000000;
-enum STT_ARM_TFUNC =           STT_LOPROC;
-enum STT_ARM_16BIT =           STT_HIPROC;
-enum SHF_ARM_ENTRYSECT =       0x10000000;
-enum SHF_ARM_COMDEF =          0x80000000;
-enum PF_ARM_SB =               0x10000000;
-enum PF_ARM_PI =               0x20000000;
-enum PF_ARM_ABS =              0x40000000;
-enum PT_ARM_EXIDX =            (PT_LOPROC + 1);
-enum SHT_ARM_EXIDX =           (SHT_LOPROC + 1);
-enum SHT_ARM_PREEMPTMAP =      (SHT_LOPROC + 2);
-enum SHT_ARM_ATTRIBUTES =      (SHT_LOPROC + 3);
-
-enum R_AARCH64_NONE =            0;
-enum R_AARCH64_ABS64 =         257;
-enum R_AARCH64_ABS32 =         258;
-enum R_AARCH64_COPY =         1024;
-enum R_AARCH64_GLOB_DAT =     1025;
-enum R_AARCH64_JUMP_SLOT =    1026;
-enum R_AARCH64_RELATIVE =     1027;
-enum R_AARCH64_TLS_DTPMOD64 = 1028;
-enum R_AARCH64_TLS_DTPREL64 = 1029;
-enum R_AARCH64_TLS_TPREL64 =  1030;
-enum R_AARCH64_TLSDESC =      1031;
-
-enum R_ARM_NONE =              0;
-enum R_ARM_PC24 =              1;
-enum R_ARM_ABS32 =             2;
-enum R_ARM_REL32 =             3;
-enum R_ARM_PC13 =              4;
-enum R_ARM_ABS16 =             5;
-enum R_ARM_ABS12 =             6;
-enum R_ARM_THM_ABS5 =          7;
-enum R_ARM_ABS8 =              8;
-enum R_ARM_SBREL32 =           9;
-enum R_ARM_THM_PC22 =          10;
-enum R_ARM_THM_PC8 =           11;
-enum R_ARM_AMP_VCALL9 =        12;
-enum R_ARM_SWI24 =             13;
-enum R_ARM_TLS_DESC =          13;
-enum R_ARM_THM_SWI8 =          14;
-enum R_ARM_XPC25 =             15;
-enum R_ARM_THM_XPC22 =         16;
-enum R_ARM_TLS_DTPMOD32 =      17;
-enum R_ARM_TLS_DTPOFF32 =      18;
-enum R_ARM_TLS_TPOFF32 =       19;
-enum R_ARM_COPY =              20;
-enum R_ARM_GLOB_DAT =          21;
-enum R_ARM_JUMP_SLOT =         22;
-enum R_ARM_RELATIVE =          23;
-enum R_ARM_GOTOFF =            24;
-enum R_ARM_GOTPC =             25;
-enum R_ARM_GOT32 =             26;
-enum R_ARM_PLT32 =             27;
-enum R_ARM_ALU_PCREL_7_0 =     32;
-enum R_ARM_ALU_PCREL_15_8 =    33;
-enum R_ARM_ALU_PCREL_23_15 =   34;
-enum R_ARM_LDR_SBREL_11_0 =    35;
-enum R_ARM_ALU_SBREL_19_12 =   36;
-enum R_ARM_ALU_SBREL_27_20 =   37;
-enum R_ARM_TLS_GOTDESC =       90;
-enum R_ARM_TLS_CALL =          91;
-enum R_ARM_TLS_DESCSEQ =       92;
-enum R_ARM_THM_TLS_CALL =      93;
-enum R_ARM_GNU_VTENTRY =       100;
-enum R_ARM_GNU_VTINHERIT =     101;
-enum R_ARM_THM_PC11 =          102;
-enum R_ARM_THM_PC9 =           103;
-enum R_ARM_TLS_GD32 =          104;
-enum R_ARM_TLS_LDM32 =         105;
-enum R_ARM_TLS_LDO32 =         106;
-enum R_ARM_TLS_IE32 =          107;
-enum R_ARM_TLS_LE32 =          108;
-enum R_ARM_THM_TLS_DESCSEQ =   129;
-enum R_ARM_IRELATIVE =         160;
-enum R_ARM_RXPC25 =            249;
-enum R_ARM_RSBREL32 =          250;
-enum R_ARM_THM_RPC22 =         251;
-enum R_ARM_RREL32 =            252;
-enum R_ARM_RABS22 =            253;
-enum R_ARM_RPC24 =             254;
-enum R_ARM_RBASE =             255;
-enum R_ARM_NUM =               256;
-enum EF_IA_64_MASKOS =         0x0000000f;
-enum EF_IA_64_ABI64 =          0x00000010;
-enum EF_IA_64_ARCH =           0xff000000;
-enum PT_IA_64_ARCHEXT =        (PT_LOPROC + 0);
-enum PT_IA_64_UNWIND =         (PT_LOPROC + 1);
-enum PT_IA_64_HP_OPT_ANOT =    (PT_LOOS + 0x12);
-enum PT_IA_64_HP_HSL_ANOT =    (PT_LOOS + 0x13);
-enum PT_IA_64_HP_STACK =       (PT_LOOS + 0x14);
-enum PF_IA_64_NORECOV =        0x80000000;
-enum SHT_IA_64_EXT =           (SHT_LOPROC + 0);
-enum SHT_IA_64_UNWIND =        (SHT_LOPROC + 1);
-enum SHF_IA_64_SHORT =         0x10000000;
-enum SHF_IA_64_NORECOV =       0x20000000;
-enum DT_IA_64_PLT_RESERVE =    (DT_LOPROC + 0);
-enum DT_IA_64_NUM =            1;
-enum R_IA64_NONE =             0x00;
-enum R_IA64_IMM14 =            0x21;
-enum R_IA64_IMM22 =            0x22;
-enum R_IA64_IMM64 =            0x23;
-enum R_IA64_DIR32MSB =         0x24;
-enum R_IA64_DIR32LSB =         0x25;
-enum R_IA64_DIR64MSB =         0x26;
-enum R_IA64_DIR64LSB =         0x27;
-enum R_IA64_GPREL22 =          0x2a;
-enum R_IA64_GPREL64I =         0x2b;
-enum R_IA64_GPREL32MSB =       0x2c;
-enum R_IA64_GPREL32LSB =       0x2d;
-enum R_IA64_GPREL64MSB =       0x2e;
-enum R_IA64_GPREL64LSB =       0x2f;
-enum R_IA64_LTOFF22 =          0x32;
-enum R_IA64_LTOFF64I =         0x33;
-enum R_IA64_PLTOFF22 =         0x3a;
-enum R_IA64_PLTOFF64I =        0x3b;
-enum R_IA64_PLTOFF64MSB =      0x3e;
-enum R_IA64_PLTOFF64LSB =      0x3f;
-enum R_IA64_FPTR64I =          0x43;
-enum R_IA64_FPTR32MSB =        0x44;
-enum R_IA64_FPTR32LSB =        0x45;
-enum R_IA64_FPTR64MSB =        0x46;
-enum R_IA64_FPTR64LSB =        0x47;
-enum R_IA64_PCREL60B =         0x48;
-enum R_IA64_PCREL21B =         0x49;
-enum R_IA64_PCREL21M =         0x4a;
-enum R_IA64_PCREL21F =         0x4b;
-enum R_IA64_PCREL32MSB =       0x4c;
-enum R_IA64_PCREL32LSB =       0x4d;
-enum R_IA64_PCREL64MSB =       0x4e;
-enum R_IA64_PCREL64LSB =       0x4f;
-enum R_IA64_LTOFF_FPTR22 =     0x52;
-enum R_IA64_LTOFF_FPTR64I =    0x53;
-enum R_IA64_LTOFF_FPTR32MSB =  0x54;
-enum R_IA64_LTOFF_FPTR32LSB =  0x55;
-enum R_IA64_LTOFF_FPTR64MSB =  0x56;
-enum R_IA64_LTOFF_FPTR64LSB =  0x57;
-enum R_IA64_SEGREL32MSB =      0x5c;
-enum R_IA64_SEGREL32LSB =      0x5d;
-enum R_IA64_SEGREL64MSB =      0x5e;
-enum R_IA64_SEGREL64LSB =      0x5f;
-enum R_IA64_SECREL32MSB =      0x64;
-enum R_IA64_SECREL32LSB =      0x65;
-enum R_IA64_SECREL64MSB =      0x66;
-enum R_IA64_SECREL64LSB =      0x67;
-enum R_IA64_REL32MSB =         0x6c;
-enum R_IA64_REL32LSB =         0x6d;
-enum R_IA64_REL64MSB =         0x6e;
-enum R_IA64_REL64LSB =         0x6f;
-enum R_IA64_LTV32MSB =         0x74;
-enum R_IA64_LTV32LSB =         0x75;
-enum R_IA64_LTV64MSB =         0x76;
-enum R_IA64_LTV64LSB =         0x77;
-enum R_IA64_PCREL21BI =        0x79;
-enum R_IA64_PCREL22 =          0x7a;
-enum R_IA64_PCREL64I =         0x7b;
-enum R_IA64_IPLTMSB =          0x80;
-enum R_IA64_IPLTLSB =          0x81;
-enum R_IA64_COPY =             0x84;
-enum R_IA64_SUB =              0x85;
-enum R_IA64_LTOFF22X =         0x86;
-enum R_IA64_LDXMOV =           0x87;
-enum R_IA64_TPREL14 =          0x91;
-enum R_IA64_TPREL22 =          0x92;
-enum R_IA64_TPREL64I =         0x93;
-enum R_IA64_TPREL64MSB =       0x96;
-enum R_IA64_TPREL64LSB =       0x97;
-enum R_IA64_LTOFF_TPREL22 =    0x9a;
-enum R_IA64_DTPMOD64MSB =      0xa6;
-enum R_IA64_DTPMOD64LSB =      0xa7;
-enum R_IA64_LTOFF_DTPMOD22 =   0xaa;
-enum R_IA64_DTPREL14 =         0xb1;
-enum R_IA64_DTPREL22 =         0xb2;
-enum R_IA64_DTPREL64I =        0xb3;
-enum R_IA64_DTPREL32MSB =      0xb4;
-enum R_IA64_DTPREL32LSB =      0xb5;
-enum R_IA64_DTPREL64MSB =      0xb6;
-enum R_IA64_DTPREL64LSB =      0xb7;
-enum R_IA64_LTOFF_DTPREL22 =   0xba;
-enum EF_SH_MACH_MASK =         0x1f;
-enum EF_SH_UNKNOWN =           0x0;
-enum EF_SH1 =                  0x1;
-enum EF_SH2 =                  0x2;
-enum EF_SH3 =                  0x3;
-enum EF_SH_DSP =               0x4;
-enum EF_SH3_DSP =              0x5;
-enum EF_SH4AL_DSP =            0x6;
-enum EF_SH3E =                 0x8;
-enum EF_SH4 =                  0x9;
-enum EF_SH2E =                 0xb;
-enum EF_SH4A =                 0xc;
-enum EF_SH2A =                 0xd;
-enum EF_SH4_NOFPU =            0x10;
-enum EF_SH4A_NOFPU =           0x11;
-enum EF_SH4_NOMMU_NOFPU =      0x12;
-enum EF_SH2A_NOFPU =           0x13;
-enum EF_SH3_NOMMU =            0x14;
-enum EF_SH2A_SH4_NOFPU =       0x15;
-enum EF_SH2A_SH3_NOFPU =       0x16;
-enum EF_SH2A_SH4 =             0x17;
-enum EF_SH2A_SH3E =            0x18;
-enum R_SH_NONE =               0;
-enum R_SH_DIR32 =              1;
-enum R_SH_REL32 =              2;
-enum R_SH_DIR8WPN =            3;
-enum R_SH_IND12W =             4;
-enum R_SH_DIR8WPL =            5;
-enum R_SH_DIR8WPZ =            6;
-enum R_SH_DIR8BP =             7;
-enum R_SH_DIR8W =              8;
-enum R_SH_DIR8L =              9;
-enum R_SH_SWITCH16 =           25;
-enum R_SH_SWITCH32 =           26;
-enum R_SH_USES =               27;
-enum R_SH_COUNT =              28;
-enum R_SH_ALIGN =              29;
-enum R_SH_CODE =               30;
-enum R_SH_DATA =               31;
-enum R_SH_LABEL =              32;
-enum R_SH_SWITCH8 =            33;
-enum R_SH_GNU_VTINHERIT =      34;
-enum R_SH_GNU_VTENTRY =        35;
-enum R_SH_TLS_GD_32 =          144;
-enum R_SH_TLS_LD_32 =          145;
-enum R_SH_TLS_LDO_32 =         146;
-enum R_SH_TLS_IE_32 =          147;
-enum R_SH_TLS_LE_32 =          148;
-enum R_SH_TLS_DTPMOD32 =       149;
-enum R_SH_TLS_DTPOFF32 =       150;
-enum R_SH_TLS_TPOFF32 =        151;
-enum R_SH_GOT32 =              160;
-enum R_SH_PLT32 =              161;
-enum R_SH_COPY =               162;
-enum R_SH_GLOB_DAT =           163;
-enum R_SH_JMP_SLOT =           164;
-enum R_SH_RELATIVE =           165;
-enum R_SH_GOTOFF =             166;
-enum R_SH_GOTPC =              167;
-enum R_SH_NUM =                256;
-
-enum EF_S390_HIGH_GPRS =    0x00000001;
-
-enum R_390_NONE =              0;
-enum R_390_8 =                 1;
-enum R_390_12 =                2;
-enum R_390_16 =                3;
-enum R_390_32 =                4;
-enum R_390_PC32 =              5;
-enum R_390_GOT12 =             6;
-enum R_390_GOT32 =             7;
-enum R_390_PLT32 =             8;
-enum R_390_COPY =              9;
-enum R_390_GLOB_DAT =          10;
-enum R_390_JMP_SLOT =          11;
-enum R_390_RELATIVE =          12;
-enum R_390_GOTOFF32 =          13;
-enum R_390_GOTPC =             14;
-enum R_390_GOT16 =             15;
-enum R_390_PC16 =              16;
-enum R_390_PC16DBL =           17;
-enum R_390_PLT16DBL =          18;
-enum R_390_PC32DBL =           19;
-enum R_390_PLT32DBL =          20;
-enum R_390_GOTPCDBL =          21;
-enum R_390_64 =                22;
-enum R_390_PC64 =              23;
-enum R_390_GOT64 =             24;
-enum R_390_PLT64 =             25;
-enum R_390_GOTENT =            26;
-enum R_390_GOTOFF16 =          27;
-enum R_390_GOTOFF64 =          28;
-enum R_390_GOTPLT12 =          29;
-enum R_390_GOTPLT16 =          30;
-enum R_390_GOTPLT32 =          31;
-enum R_390_GOTPLT64 =          32;
-enum R_390_GOTPLTENT =         33;
-enum R_390_PLTOFF16 =          34;
-enum R_390_PLTOFF32 =          35;
-enum R_390_PLTOFF64 =          36;
-enum R_390_TLS_LOAD =          37;
-enum R_390_TLS_GDCALL =        38;
-enum R_390_TLS_LDCALL =        39;
-enum R_390_TLS_GD32 =          40;
-enum R_390_TLS_GD64 =          41;
-enum R_390_TLS_GOTIE12 =       42;
-enum R_390_TLS_GOTIE32 =       43;
-enum R_390_TLS_GOTIE64 =       44;
-enum R_390_TLS_LDM32 =         45;
-enum R_390_TLS_LDM64 =         46;
-enum R_390_TLS_IE32 =          47;
-enum R_390_TLS_IE64 =          48;
-enum R_390_TLS_IEENT =         49;
-enum R_390_TLS_LE32 =          50;
-enum R_390_TLS_LE64 =          51;
-enum R_390_TLS_LDO32 =         52;
-enum R_390_TLS_LDO64 =         53;
-enum R_390_TLS_DTPMOD =        54;
-enum R_390_TLS_DTPOFF =        55;
-enum R_390_TLS_TPOFF =         56;
-enum R_390_20 =                57;
-enum R_390_GOT20 =             58;
-enum R_390_GOTPLT20 =          59;
-enum R_390_TLS_GOTIE20 =       60;
-enum R_390_IRELATIVE =         61;
-enum R_390_NUM =               62;
-enum R_CRIS_NONE =             0;
-enum R_CRIS_8 =                1;
-enum R_CRIS_16 =               2;
-enum R_CRIS_32 =               3;
-enum R_CRIS_8_PCREL =          4;
-enum R_CRIS_16_PCREL =         5;
-enum R_CRIS_32_PCREL =         6;
-enum R_CRIS_GNU_VTINHERIT =    7;
-enum R_CRIS_GNU_VTENTRY =      8;
-enum R_CRIS_COPY =             9;
-enum R_CRIS_GLOB_DAT =         10;
-enum R_CRIS_JUMP_SLOT =        11;
-enum R_CRIS_RELATIVE =         12;
-enum R_CRIS_16_GOT =           13;
-enum R_CRIS_32_GOT =           14;
-enum R_CRIS_16_GOTPLT =        15;
-enum R_CRIS_32_GOTPLT =        16;
-enum R_CRIS_32_GOTREL =        17;
-enum R_CRIS_32_PLT_GOTREL =    18;
-enum R_CRIS_32_PLT_PCREL =     19;
-
-enum R_CRIS_NUM =              20;
-enum R_X86_64_NONE =           0;
-enum R_X86_64_64 =             1;
-enum R_X86_64_PC32 =           2;
-enum R_X86_64_GOT32 =          3;
-enum R_X86_64_PLT32 =          4;
-enum R_X86_64_COPY =           5;
-enum R_X86_64_GLOB_DAT =       6;
-enum R_X86_64_JUMP_SLOT =      7;
-enum R_X86_64_RELATIVE =       8;
-enum R_X86_64_GOTPCREL =       9;
-enum R_X86_64_32 =             10;
-enum R_X86_64_32S =            11;
-enum R_X86_64_16 =             12;
-enum R_X86_64_PC16 =           13;
-enum R_X86_64_8 =              14;
-enum R_X86_64_PC8 =            15;
-enum R_X86_64_DTPMOD64 =       16;
-enum R_X86_64_DTPOFF64 =       17;
-enum R_X86_64_TPOFF64 =        18;
-enum R_X86_64_TLSGD =          19;
-enum R_X86_64_TLSLD =          20;
-enum R_X86_64_DTPOFF32 =       21;
-enum R_X86_64_GOTTPOFF =       22;
-enum R_X86_64_TPOFF32 =        23;
-enum R_X86_64_PC64 =           24;
-enum R_X86_64_GOTOFF64 =       25;
-enum R_X86_64_GOTPC32 =        26;
-enum R_X86_64_GOT64 =          27;
-enum R_X86_64_GOTPCREL64 =     28;
-enum R_X86_64_GOTPC64 =        29;
-enum R_X86_64_GOTPLT64 =       30;
-enum R_X86_64_PLTOFF64 =       31;
-enum R_X86_64_SIZE32 =         32;
-enum R_X86_64_SIZE64 =         33;
-enum R_X86_64_GOTPC32_TLSDESC = 34;
-enum R_X86_64_TLSDESC_CALL =   35;
-enum R_X86_64_TLSDESC =        36;
-enum R_X86_64_IRELATIVE =      37;
-enum R_X86_64_RELATIVE64 =     38;
-
-enum R_X86_64_NUM =            39;
-enum R_MN10300_NONE =          0;
-enum R_MN10300_32 =            1;
-enum R_MN10300_16 =            2;
-enum R_MN10300_8 =             3;
-enum R_MN10300_PCREL32 =       4;
-enum R_MN10300_PCREL16 =       5;
-enum R_MN10300_PCREL8 =        6;
-enum R_MN10300_GNU_VTINHERIT = 7;
-enum R_MN10300_GNU_VTENTRY =   8;
-enum R_MN10300_24 =            9;
-enum R_MN10300_GOTPC32 =       10;
-enum R_MN10300_GOTPC16 =       11;
-enum R_MN10300_GOTOFF32 =      12;
-enum R_MN10300_GOTOFF24 =      13;
-enum R_MN10300_GOTOFF16 =      14;
-enum R_MN10300_PLT32 =         15;
-enum R_MN10300_PLT16 =         16;
-enum R_MN10300_GOT32 =         17;
-enum R_MN10300_GOT24 =         18;
-enum R_MN10300_GOT16 =         19;
-enum R_MN10300_COPY =          20;
-enum R_MN10300_GLOB_DAT =      21;
-enum R_MN10300_JMP_SLOT =      22;
-enum R_MN10300_RELATIVE =      23;
-enum R_MN10300_TLS_GD =        24;
-enum R_MN10300_TLS_LD =        25;
-enum R_MN10300_TLS_LDO =       26;
-enum R_MN10300_TLS_GOTIE =     27;
-enum R_MN10300_TLS_IE =        28;
-enum R_MN10300_TLS_LE =        29;
-enum R_MN10300_TLS_DTPMOD =    30;
-enum R_MN10300_TLS_DTPOFF =    31;
-enum R_MN10300_TLS_TPOFF =     32;
-enum R_MN10300_SYM_DIFF =      33;
-enum R_MN10300_ALIGN =         34;
-enum R_MN10300_NUM =           35;
-enum R_M32R_NONE =             0;
-enum R_M32R_16 =               1;
-enum R_M32R_32 =               2;
-enum R_M32R_24 =               3;
-enum R_M32R_10_PCREL =         4;
-enum R_M32R_18_PCREL =         5;
-enum R_M32R_26_PCREL =         6;
-enum R_M32R_HI16_ULO =         7;
-enum R_M32R_HI16_SLO =         8;
-enum R_M32R_LO16 =             9;
-enum R_M32R_SDA16 =            10;
-enum R_M32R_GNU_VTINHERIT =    11;
-enum R_M32R_GNU_VTENTRY =      12;
-enum R_M32R_16_RELA =          33;
-enum R_M32R_32_RELA =          34;
-enum R_M32R_24_RELA =          35;
-enum R_M32R_10_PCREL_RELA =    36;
-enum R_M32R_18_PCREL_RELA =    37;
-enum R_M32R_26_PCREL_RELA =    38;
-enum R_M32R_HI16_ULO_RELA =    39;
-enum R_M32R_HI16_SLO_RELA =    40;
-enum R_M32R_LO16_RELA =        41;
-enum R_M32R_SDA16_RELA =       42;
-enum R_M32R_RELA_GNU_VTINHERIT =       43;
-enum R_M32R_RELA_GNU_VTENTRY = 44;
-enum R_M32R_REL32 =            45;
-
-enum R_M32R_GOT24 =            48;
-enum R_M32R_26_PLTREL =        49;
-enum R_M32R_COPY =             50;
-enum R_M32R_GLOB_DAT =         51;
-enum R_M32R_JMP_SLOT =         52;
-enum R_M32R_RELATIVE =         53;
-enum R_M32R_GOTOFF =           54;
-enum R_M32R_GOTPC24 =          55;
-enum R_M32R_GOT16_HI_ULO =     56;
-enum R_M32R_GOT16_HI_SLO =     57;
-enum R_M32R_GOT16_LO =         58;
-enum R_M32R_GOTPC_HI_ULO =     59;
-enum R_M32R_GOTPC_HI_SLO =     60;
-enum R_M32R_GOTPC_LO =         61;
-enum R_M32R_GOTOFF_HI_ULO =    62;
-enum R_M32R_GOTOFF_HI_SLO =    63;
-enum R_M32R_GOTOFF_LO =        64;
-enum R_M32R_NUM =              256;
-enum R_TILEPRO_NONE =          0;
-enum R_TILEPRO_32 =            1;
-enum R_TILEPRO_16 =            2;
-enum R_TILEPRO_8 =             3;
-enum R_TILEPRO_32_PCREL =      4;
-enum R_TILEPRO_16_PCREL =      5;
-enum R_TILEPRO_8_PCREL =       6;
-enum R_TILEPRO_LO16 =          7;
-enum R_TILEPRO_HI16 =          8;
-enum R_TILEPRO_HA16 =          9;
-enum R_TILEPRO_COPY =          10;
-enum R_TILEPRO_GLOB_DAT =      11;
-enum R_TILEPRO_JMP_SLOT =      12;
-enum R_TILEPRO_RELATIVE =      13;
-enum R_TILEPRO_BROFF_X1 =      14;
-enum R_TILEPRO_JOFFLONG_X1 =   15;
-enum R_TILEPRO_JOFFLONG_X1_PLT = 16;
-enum R_TILEPRO_IMM8_X0 =       17;
-enum R_TILEPRO_IMM8_Y0 =       18;
-enum R_TILEPRO_IMM8_X1 =       19;
-enum R_TILEPRO_IMM8_Y1 =       20;
-enum R_TILEPRO_MT_IMM15_X1 =   21;
-enum R_TILEPRO_MF_IMM15_X1 =   22;
-enum R_TILEPRO_IMM16_X0 =      23;
-enum R_TILEPRO_IMM16_X1 =      24;
-enum R_TILEPRO_IMM16_X0_LO =   25;
-enum R_TILEPRO_IMM16_X1_LO =   26;
-enum R_TILEPRO_IMM16_X0_HI =   27;
-enum R_TILEPRO_IMM16_X1_HI =   28;
-enum R_TILEPRO_IMM16_X0_HA =   29;
-enum R_TILEPRO_IMM16_X1_HA =   30;
-enum R_TILEPRO_IMM16_X0_PCREL = 31;
-enum R_TILEPRO_IMM16_X1_PCREL = 32;
-enum R_TILEPRO_IMM16_X0_LO_PCREL = 33;
-enum R_TILEPRO_IMM16_X1_LO_PCREL = 34;
-enum R_TILEPRO_IMM16_X0_HI_PCREL = 35;
-enum R_TILEPRO_IMM16_X1_HI_PCREL = 36;
-enum R_TILEPRO_IMM16_X0_HA_PCREL = 37;
-enum R_TILEPRO_IMM16_X1_HA_PCREL = 38;
-enum R_TILEPRO_IMM16_X0_GOT =  39;
-enum R_TILEPRO_IMM16_X1_GOT =  40;
-enum R_TILEPRO_IMM16_X0_GOT_LO = 41;
-enum R_TILEPRO_IMM16_X1_GOT_LO = 42;
-enum R_TILEPRO_IMM16_X0_GOT_HI = 43;
-enum R_TILEPRO_IMM16_X1_GOT_HI = 44;
-enum R_TILEPRO_IMM16_X0_GOT_HA = 45;
-enum R_TILEPRO_IMM16_X1_GOT_HA = 46;
-enum R_TILEPRO_MMSTART_X0 =    47;
-enum R_TILEPRO_MMEND_X0 =      48;
-enum R_TILEPRO_MMSTART_X1 =    49;
-enum R_TILEPRO_MMEND_X1 =      50;
-enum R_TILEPRO_SHAMT_X0 =      51;
-enum R_TILEPRO_SHAMT_X1 =      52;
-enum R_TILEPRO_SHAMT_Y0 =      53;
-enum R_TILEPRO_SHAMT_Y1 =      54;
-enum R_TILEPRO_DEST_IMM8_X1 =  55;
-enum R_TILEPRO_TLS_GD_CALL =   60;
-enum R_TILEPRO_IMM8_X0_TLS_GD_ADD = 61;
-enum R_TILEPRO_IMM8_X1_TLS_GD_ADD = 62;
-enum R_TILEPRO_IMM8_Y0_TLS_GD_ADD = 63;
-enum R_TILEPRO_IMM8_Y1_TLS_GD_ADD = 64;
-enum R_TILEPRO_TLS_IE_LOAD =   65;
-enum R_TILEPRO_IMM16_X0_TLS_GD = 66;
-enum R_TILEPRO_IMM16_X1_TLS_GD = 67;
-enum R_TILEPRO_IMM16_X0_TLS_GD_LO = 68;
-enum R_TILEPRO_IMM16_X1_TLS_GD_LO = 69;
-enum R_TILEPRO_IMM16_X0_TLS_GD_HI = 70;
-enum R_TILEPRO_IMM16_X1_TLS_GD_HI = 71;
-enum R_TILEPRO_IMM16_X0_TLS_GD_HA = 72;
-enum R_TILEPRO_IMM16_X1_TLS_GD_HA = 73;
-enum R_TILEPRO_IMM16_X0_TLS_IE = 74;
-enum R_TILEPRO_IMM16_X1_TLS_IE = 75;
-enum R_TILEPRO_IMM16_X0_TLS_IE_LO = 76;
-enum R_TILEPRO_IMM16_X1_TLS_IE_LO = 77;
-enum R_TILEPRO_IMM16_X0_TLS_IE_HI = 78;
-enum R_TILEPRO_IMM16_X1_TLS_IE_HI = 79;
-enum R_TILEPRO_IMM16_X0_TLS_IE_HA = 80;
-enum R_TILEPRO_IMM16_X1_TLS_IE_HA = 81;
-enum R_TILEPRO_TLS_DTPMOD32 =  82;
-enum R_TILEPRO_TLS_DTPOFF32 =  83;
-enum R_TILEPRO_TLS_TPOFF32 =   84;
-enum R_TILEPRO_IMM16_X0_TLS_LE = 85;
-enum R_TILEPRO_IMM16_X1_TLS_LE = 86;
-enum R_TILEPRO_IMM16_X0_TLS_LE_LO = 87;
-enum R_TILEPRO_IMM16_X1_TLS_LE_LO = 88;
-enum R_TILEPRO_IMM16_X0_TLS_LE_HI = 89;
-enum R_TILEPRO_IMM16_X1_TLS_LE_HI = 90;
-enum R_TILEPRO_IMM16_X0_TLS_LE_HA = 91;
-enum R_TILEPRO_IMM16_X1_TLS_LE_HA = 92;
-
-enum R_TILEPRO_GNU_VTINHERIT = 128;
-enum R_TILEPRO_GNU_VTENTRY =   129;
-
-enum R_TILEPRO_NUM =           130;
-enum R_TILEGX_NONE =           0;
-enum R_TILEGX_64 =             1;
-enum R_TILEGX_32 =             2;
-enum R_TILEGX_16 =             3;
-enum R_TILEGX_8 =              4;
-enum R_TILEGX_64_PCREL =       5;
-enum R_TILEGX_32_PCREL =       6;
-enum R_TILEGX_16_PCREL =       7;
-enum R_TILEGX_8_PCREL =        8;
-enum R_TILEGX_HW0 =            9;
-enum R_TILEGX_HW1 =            10;
-enum R_TILEGX_HW2 =            11;
-enum R_TILEGX_HW3 =            12;
-enum R_TILEGX_HW0_LAST =       13;
-enum R_TILEGX_HW1_LAST =       14;
-enum R_TILEGX_HW2_LAST =       15;
-enum R_TILEGX_COPY =           16;
-enum R_TILEGX_GLOB_DAT =       17;
-enum R_TILEGX_JMP_SLOT =       18;
-enum R_TILEGX_RELATIVE =       19;
-enum R_TILEGX_BROFF_X1 =       20;
-enum R_TILEGX_JUMPOFF_X1 =     21;
-enum R_TILEGX_JUMPOFF_X1_PLT = 22;
-enum R_TILEGX_IMM8_X0 =        23;
-enum R_TILEGX_IMM8_Y0 =        24;
-enum R_TILEGX_IMM8_X1 =        25;
-enum R_TILEGX_IMM8_Y1 =        26;
-enum R_TILEGX_DEST_IMM8_X1 =   27;
-enum R_TILEGX_MT_IMM14_X1 =    28;
-enum R_TILEGX_MF_IMM14_X1 =    29;
-enum R_TILEGX_MMSTART_X0 =     30;
-enum R_TILEGX_MMEND_X0 =       31;
-enum R_TILEGX_SHAMT_X0 =       32;
-enum R_TILEGX_SHAMT_X1 =       33;
-enum R_TILEGX_SHAMT_Y0 =       34;
-enum R_TILEGX_SHAMT_Y1 =       35;
-enum R_TILEGX_IMM16_X0_HW0 =   36;
-enum R_TILEGX_IMM16_X1_HW0 =   37;
-enum R_TILEGX_IMM16_X0_HW1 =   38;
-enum R_TILEGX_IMM16_X1_HW1 =   39;
-enum R_TILEGX_IMM16_X0_HW2 =   40;
-enum R_TILEGX_IMM16_X1_HW2 =   41;
-enum R_TILEGX_IMM16_X0_HW3 =   42;
-enum R_TILEGX_IMM16_X1_HW3 =   43;
-enum R_TILEGX_IMM16_X0_HW0_LAST = 44;
-enum R_TILEGX_IMM16_X1_HW0_LAST = 45;
-enum R_TILEGX_IMM16_X0_HW1_LAST = 46;
-enum R_TILEGX_IMM16_X1_HW1_LAST = 47;
-enum R_TILEGX_IMM16_X0_HW2_LAST = 48;
-enum R_TILEGX_IMM16_X1_HW2_LAST = 49;
-enum R_TILEGX_IMM16_X0_HW0_PCREL = 50;
-enum R_TILEGX_IMM16_X1_HW0_PCREL = 51;
-enum R_TILEGX_IMM16_X0_HW1_PCREL = 52;
-enum R_TILEGX_IMM16_X1_HW1_PCREL = 53;
-enum R_TILEGX_IMM16_X0_HW2_PCREL = 54;
-enum R_TILEGX_IMM16_X1_HW2_PCREL = 55;
-enum R_TILEGX_IMM16_X0_HW3_PCREL = 56;
-enum R_TILEGX_IMM16_X1_HW3_PCREL = 57;
-enum R_TILEGX_IMM16_X0_HW0_LAST_PCREL = 58;
-enum R_TILEGX_IMM16_X1_HW0_LAST_PCREL = 59;
-enum R_TILEGX_IMM16_X0_HW1_LAST_PCREL = 60;
-enum R_TILEGX_IMM16_X1_HW1_LAST_PCREL = 61;
-enum R_TILEGX_IMM16_X0_HW2_LAST_PCREL = 62;
-enum R_TILEGX_IMM16_X1_HW2_LAST_PCREL = 63;
-enum R_TILEGX_IMM16_X0_HW0_GOT = 64;
-enum R_TILEGX_IMM16_X1_HW0_GOT = 65;
-enum R_TILEGX_IMM16_X0_HW0_PLT_PCREL = 66;
-enum R_TILEGX_IMM16_X1_HW0_PLT_PCREL = 67;
-enum R_TILEGX_IMM16_X0_HW1_PLT_PCREL = 68;
-enum R_TILEGX_IMM16_X1_HW1_PLT_PCREL = 69;
-enum R_TILEGX_IMM16_X0_HW2_PLT_PCREL = 70;
-enum R_TILEGX_IMM16_X1_HW2_PLT_PCREL = 71;
-enum R_TILEGX_IMM16_X0_HW0_LAST_GOT = 72;
-enum R_TILEGX_IMM16_X1_HW0_LAST_GOT = 73;
-enum R_TILEGX_IMM16_X0_HW1_LAST_GOT = 74;
-enum R_TILEGX_IMM16_X1_HW1_LAST_GOT = 75;
-enum R_TILEGX_IMM16_X0_HW3_PLT_PCREL = 76;
-enum R_TILEGX_IMM16_X1_HW3_PLT_PCREL = 77;
-enum R_TILEGX_IMM16_X0_HW0_TLS_GD = 78;
-enum R_TILEGX_IMM16_X1_HW0_TLS_GD = 79;
-enum R_TILEGX_IMM16_X0_HW0_TLS_LE = 80;
-enum R_TILEGX_IMM16_X1_HW0_TLS_LE = 81;
-enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE = 82;
-enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE = 83;
-enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE = 84;
-enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE = 85;
-enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD = 86;
-enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD = 87;
-enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD = 88;
-enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD = 89;
-enum R_TILEGX_IMM16_X0_HW0_TLS_IE = 92;
-enum R_TILEGX_IMM16_X1_HW0_TLS_IE = 93;
-enum R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL = 94;
-enum R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL = 95;
-enum R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL = 96;
-enum R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL = 97;
-enum R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL = 98;
-enum R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL = 99;
-enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE = 100;
-enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE = 101;
-enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE = 102;
-enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE = 103;
-enum R_TILEGX_TLS_DTPMOD64 =   106;
-enum R_TILEGX_TLS_DTPOFF64 =   107;
-enum R_TILEGX_TLS_TPOFF64 =    108;
-enum R_TILEGX_TLS_DTPMOD32 =   109;
-enum R_TILEGX_TLS_DTPOFF32 =   110;
-enum R_TILEGX_TLS_TPOFF32 =    111;
-enum R_TILEGX_TLS_GD_CALL =    112;
-enum R_TILEGX_IMM8_X0_TLS_GD_ADD = 113;
-enum R_TILEGX_IMM8_X1_TLS_GD_ADD = 114;
-enum R_TILEGX_IMM8_Y0_TLS_GD_ADD = 115;
-enum R_TILEGX_IMM8_Y1_TLS_GD_ADD = 116;
-enum R_TILEGX_TLS_IE_LOAD =    117;
-enum R_TILEGX_IMM8_X0_TLS_ADD = 118;
-enum R_TILEGX_IMM8_X1_TLS_ADD = 119;
-enum R_TILEGX_IMM8_Y0_TLS_ADD = 120;
-enum R_TILEGX_IMM8_Y1_TLS_ADD = 121;
-
-enum R_TILEGX_GNU_VTINHERIT =  128;
-enum R_TILEGX_GNU_VTENTRY =    129;
-
-enum R_TILEGX_NUM =            130;
index ac623d6955d2e79faf40b7b700bf293b429be2f5..ce7d8bade3f122924273fac08ec133d7b6e74d2d 100644 (file)
@@ -13,108 +13,13 @@ nothrow:
 import core.stdc.stdint;
 public import core.sys.netbsd.sys.elf_common;
 
-alias uint16_t Elf32_Half;
-alias uint32_t Elf32_Word;
-alias int32_t  Elf32_Sword;
 alias uint64_t Elf32_Lword;
-alias uint32_t Elf32_Addr;
-alias uint32_t Elf32_Off;
 alias Elf32_Word Elf32_Hashelt;
 alias Elf32_Word Elf32_Size;
 alias Elf32_Sword Elf32_Ssize;
 
-struct Elf32_Ehdr
-{
-    char[EI_NIDENT] e_ident = 0;
-    Elf32_Half    e_type;
-    Elf32_Half    e_machine;
-    Elf32_Word    e_version;
-    Elf32_Addr    e_entry;
-    Elf32_Off     e_phoff;
-    Elf32_Off     e_shoff;
-    Elf32_Word    e_flags;
-    Elf32_Half    e_ehsize;
-    Elf32_Half    e_phentsize;
-    Elf32_Half    e_phnum;
-    Elf32_Half    e_shentsize;
-    Elf32_Half    e_shnum;
-    Elf32_Half    e_shstrndx;
-}
-
-struct Elf32_Shdr
-{
-    Elf32_Word    sh_name;
-    Elf32_Word    sh_type;
-    Elf32_Word    sh_flags;
-    Elf32_Addr    sh_addr;
-    Elf32_Off     sh_offset;
-    Elf32_Word    sh_size;
-    Elf32_Word    sh_link;
-    Elf32_Word    sh_info;
-    Elf32_Word    sh_addralign;
-    Elf32_Word    sh_entsize;
-}
-
-struct Elf32_Phdr
-{
-    Elf32_Word    p_type;
-    Elf32_Off     p_offset;
-    Elf32_Addr    p_vaddr;
-    Elf32_Addr    p_paddr;
-    Elf32_Word    p_filesz;
-    Elf32_Word    p_memsz;
-    Elf32_Word    p_flags;
-    Elf32_Word    p_align;
-}
-
-struct Elf32_Dyn
-{
-  Elf32_Sword   d_tag;
-  union _d_un
-  {
-      Elf32_Word d_val;
-      Elf32_Addr d_ptr;
-  } _d_un d_un;
-}
-
-struct Elf32_Rel
-{
-    Elf32_Addr    r_offset;
-    Elf32_Word    r_info;
-}
-
-struct Elf32_Rela
-{
-    Elf32_Addr    r_offset;
-    Elf32_Word    r_info;
-    Elf32_Sword   r_addend;
-}
-
-extern (D)
-{
-    auto ELF32_R_SYM(V)(V val) { return val >> 8; }
-    auto ELF32_R_TYPE(V)(V val) { return val & 0xff; }
-    auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); }
-}
-
 alias Elf_Note Elf32_Nhdr;
 
-struct Elf32_Move
-{
-    Elf32_Lword   m_value;
-    Elf32_Word    m_info;
-    Elf32_Word    m_poffset;
-    Elf32_Half    m_repeat;
-    Elf32_Half    m_stride;
-}
-
-extern (D)
-{
-    auto ELF32_M_SYM(I)(I info) { return info >> 8; }
-    auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; }
-    auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; }
-}
-
 struct Elf32_Cap
 {
     Elf32_Word    c_tag;
@@ -125,63 +30,7 @@ struct Elf32_Cap
     } _c_un c_un;
 }
 
-struct Elf32_Sym
-{
-    Elf32_Word    st_name;
-    Elf32_Addr    st_value;
-    Elf32_Word    st_size;
-    ubyte st_info;
-    ubyte st_other;
-    Elf32_Half st_shndx;
-}
-
 extern (D)
 {
-    auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
-    auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; }
-    auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); }
     auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; }
 }
-
-struct Elf32_Verdef
-{
-    Elf32_Half    vd_version;
-    Elf32_Half    vd_flags;
-    Elf32_Half    vd_ndx;
-    Elf32_Half    vd_cnt;
-    Elf32_Word    vd_hash;
-    Elf32_Word    vd_aux;
-    Elf32_Word    vd_next;
-}
-
-struct Elf32_Verdaux
-{
-    Elf32_Word    vda_name;
-    Elf32_Word    vda_next;
-}
-
-struct Elf32_Verneed
-{
-    Elf32_Half    vn_version;
-    Elf32_Half    vn_cnt;
-    Elf32_Word    vn_file;
-    Elf32_Word    vn_aux;
-    Elf32_Word    vn_next;
-}
-
-struct Elf32_Vernaux
-{
-    Elf32_Word    vna_hash;
-    Elf32_Half    vna_flags;
-    Elf32_Half    vna_other;
-    Elf32_Word    vna_name;
-    Elf32_Word    vna_next;
-}
-
-alias Elf32_Half Elf32_Versym;
-
-struct Elf32_Syminfo
-{
-    Elf32_Half si_boundto;
-    Elf32_Half si_flags;
-}
index 659ac4054fb0191b059b8c8ca304cd387f3c73b6..7fa9a8b4de4dd35e7b40426ad53d5a4126171586 100644 (file)
@@ -13,91 +13,13 @@ nothrow:
 import core.stdc.stdint;
 public import core.sys.netbsd.sys.elf_common;
 
-alias uint16_t Elf64_Half;
-alias uint32_t Elf64_Word;
-alias int32_t  Elf64_Sword;
 alias uint64_t Elf64_Lword;
-alias uint64_t Elf64_Xword;
-alias int64_t  Elf64_Sxword;
-alias uint64_t Elf64_Addr;
-alias uint64_t Elf64_Off;
 alias Elf64_Word Elf64_Hashelt;
 alias Elf64_Xword Elf64_Size;
 alias Elf64_Sxword Elf64_Ssize;
 
-struct Elf64_Ehdr
-{
-    char[EI_NIDENT] e_ident = 0;
-    Elf64_Half    e_type;
-    Elf64_Half    e_machine;
-    Elf64_Word    e_version;
-    Elf64_Addr    e_entry;
-    Elf64_Off     e_phoff;
-    Elf64_Off     e_shoff;
-    Elf64_Word    e_flags;
-    Elf64_Half    e_ehsize;
-    Elf64_Half    e_phentsize;
-    Elf64_Half    e_phnum;
-    Elf64_Half    e_shentsize;
-    Elf64_Half    e_shnum;
-    Elf64_Half    e_shstrndx;
-}
-
-struct Elf64_Shdr
-{
-    Elf64_Word    sh_name;
-    Elf64_Word    sh_type;
-    Elf64_Xword   sh_flags;
-    Elf64_Addr    sh_addr;
-    Elf64_Off     sh_offset;
-    Elf64_Xword   sh_size;
-    Elf64_Word    sh_link;
-    Elf64_Word    sh_info;
-    Elf64_Xword   sh_addralign;
-    Elf64_Xword   sh_entsize;
-}
-
-struct Elf64_Phdr
-{
-    Elf64_Word    p_type;
-    Elf64_Word    p_flags;
-    Elf64_Off     p_offset;
-    Elf64_Addr    p_vaddr;
-    Elf64_Addr    p_paddr;
-    Elf64_Xword   p_filesz;
-    Elf64_Xword   p_memsz;
-    Elf64_Xword   p_align;
-}
-
-struct Elf64_Dyn
-{
-  Elf64_Sxword  d_tag;
-  union _d_un
-  {
-      Elf64_Xword d_val;
-      Elf64_Addr d_ptr;
-  } _d_un d_un;
-}
-
-struct Elf64_Rel
-{
-    Elf64_Addr    r_offset;
-    Elf64_Xword   r_info;
-}
-
-struct Elf64_Rela
-{
-    Elf64_Addr    r_offset;
-    Elf64_Xword   r_info;
-    Elf64_Sxword  r_addend;
-}
-
 extern (D)
 {
-    auto ELF64_R_SYM(I)(I i) { return i >> 32; }
-    auto ELF64_R_TYPE(I)(I i) { return i & 0xffffffff; }
-    auto ELF64_R_INFO(S, T)(S sym, T type) { return (sym << 32) + (type & 0xffffffff); }
-
     auto ELF64_R_TYPE_DATA(I)(I i) { return (cast(Elf64_Xword) i << 32) >> 40; }
     auto ELF64_R_TYPE_ID(I)(I i) { return (cast(Elf64_Xword) i << 56 ) >> 56; }
     auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; }
@@ -105,22 +27,6 @@ extern (D)
 
 alias Elf_Note Elf64_Nhdr;
 
-struct Elf64_Move
-{
-    Elf64_Lword   m_value;
-    Elf64_Xword   m_info;
-    Elf64_Xword   m_poffset;
-    Elf64_Half    m_repeat;
-    Elf64_Half    m_stride;
-}
-
-extern (D)
-{
-    auto ELF64_M_SYM(I)(I info) { return info >> 8; }
-    auto ELF64_M_SIZE(I)(I info) { return cast(ubyte)info; }
-    auto ELF64_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; }
-}
-
 struct Elf64_Cap
 {
     Elf64_Xword   c_tag;
@@ -131,63 +37,7 @@ struct Elf64_Cap
     } _c_un c_un;
 }
 
-struct Elf64_Sym
-{
-    Elf64_Word    st_name;
-    ubyte st_info;
-    ubyte st_other;
-    Elf64_Half st_shndx;
-    Elf64_Addr    st_value;
-    Elf64_Xword   st_size;
-}
-
 extern (D)
 {
-    auto ELF64_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
-    auto ELF64_ST_TYPE(T)(T val) { return val & 0xf; }
-    auto ELF64_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); }
     auto ELF64_ST_VISIBILITY(O)(O o) { return o & 0x03; }
 }
-
-struct Elf64_Verdef
-{
-    Elf64_Half    vd_version;
-    Elf64_Half    vd_flags;
-    Elf64_Half    vd_ndx;
-    Elf64_Half    vd_cnt;
-    Elf64_Word    vd_hash;
-    Elf64_Word    vd_aux;
-    Elf64_Word    vd_next;
-}
-
-struct Elf64_Verdaux
-{
-    Elf64_Word    vda_name;
-    Elf64_Word    vda_next;
-}
-
-struct Elf64_Verneed
-{
-    Elf64_Half    vn_version;
-    Elf64_Half    vn_cnt;
-    Elf64_Word    vn_file;
-    Elf64_Word    vn_aux;
-    Elf64_Word    vn_next;
-}
-
-struct Elf64_Vernaux
-{
-    Elf64_Word    vna_hash;
-    Elf64_Half    vna_flags;
-    Elf64_Half    vna_other;
-    Elf64_Word    vna_name;
-    Elf64_Word    vna_next;
-}
-
-alias Elf64_Half Elf64_Versym;
-
-struct Elf64_Syminfo
-{
-    Elf64_Half si_boundto;
-    Elf64_Half si_flags;
-}
index 91d8933995efde71ddc9f32f473e75838f8b8135..6c911bdc6b9c45c76b76795cdd73bcfe384d9966 100644 (file)
@@ -11,6 +11,7 @@ pure:
 nothrow:
 
 import core.stdc.stdint;
+public import core.sys.elf;
 
 struct Elf_Note
 {
@@ -27,58 +28,7 @@ struct Elf_GNU_Hash_Header
     uint32_t      gh_shift2;
 }
 
-enum EI_MAG0 =         0;
-enum EI_MAG1 =         1;
-enum EI_MAG2 =         2;
-enum EI_MAG3 =         3;
-enum EI_CLASS =        4;
-enum EI_DATA =         5;
-enum EI_VERSION =      6;
-enum EI_OSABI =        7;
-enum EI_ABIVERSION =   8;
 enum OLD_EI_BRAND =    8;
-enum EI_PAD =          9;
-enum EI_NIDENT =       16;
-
-enum ELFMAG0 =         0x7f;
-enum ELFMAG1 =         'E';
-enum ELFMAG2 =         'L';
-enum ELFMAG3 =         'F';
-enum ELFMAG =          "\177ELF";
-enum SELFMAG =         4;
-
-enum EV_NONE =         0;
-enum EV_CURRENT =      1;
-
-enum ELFCLASSNONE =    0;
-enum ELFCLASS32 =      1;
-enum ELFCLASS64 =      2;
-
-enum ELFDATANONE =     0;
-enum ELFDATA2LSB =     1;
-enum ELFDATA2MSB =     2;
-
-enum ELFOSABI_NONE =           0;
-enum ELFOSABI_SYSV =           0;
-enum ELFOSABI_HPUX =           1;
-enum ELFOSABI_NETBSD =         2;
-enum ELFOSABI_LINUX =          3;
-enum ELFOSABI_HURD  =          4;
-enum ELFOSABI_86OPEN =         5;
-enum ELFOSABI_SOLARIS =        6;
-enum ELFOSABI_AIX =            7;
-enum ELFOSABI_MONTEREY =       7;
-enum ELFOSABI_IRIX =           8;
-enum ELFOSABI_FREEBSD =        9;
-enum ELFOSABI_TRU64 =          10;
-enum ELFOSABI_MODESTO =        11;
-enum ELFOSABI_OPENBSD =        12;
-enum ELFOSABI_OPENVMS =        13;
-enum ELFOSABI_NSK =            14;
-enum ELFOSABI_AROS =           15;
-enum ELFOSABI_ARM =            97;
-enum ELFOSABI_STANDALONE =     255;
-enum ELFOSABI_DRAGONFLYBSD =   ELFOSABI_NONE;
 
 extern (D)
 {
@@ -88,310 +38,31 @@ extern (D)
                                     ehdr.e_ident[EI_MAG3] == ELFMAG3; }
 }
 
-enum ET_NONE =         0;
-enum ET_REL =          1;
-enum ET_EXEC =         2;
-enum ET_DYN =          3;
-enum ET_CORE =         4;
-enum ET_LOOS =         0xfe00;
-enum ET_HIOS =         0xfeff;
-enum ET_LOPROC =       0xff00;
-enum ET_HIPROC =       0xffff;
-
-enum EM_NONE =          0;
-enum EM_M32 =           1;
-enum EM_SPARC =         2;
-enum EM_386 =           3;
-enum EM_68K =           4;
-enum EM_88K =           5;
-enum EM_860 =           7;
-enum EM_MIPS =          8;
-enum EM_S370 =          9;
-enum EM_MIPS_RS3_LE =  10;
-enum EM_PARISC =       15;
-enum EM_VPP500 =       17;
-enum EM_SPARC32PLUS =  18;
-enum EM_960 =          19;
-enum EM_PPC =          20;
-enum EM_PPC64 =        21;
-enum EM_S390 =         22;
-enum EM_V800 =         36;
-enum EM_FR20 =         37;
-enum EM_RH32 =         38;
-enum EM_RCE =          39;
-enum EM_ARM =          40;
-enum EM_SH =           42;
-enum EM_SPARCV9 =      43;
-enum EM_TRICORE =      44;
-enum EM_ARC =          45;
-enum EM_H8_300 =       46;
-enum EM_H8_300H =      47;
-enum EM_H8S =          48;
-enum EM_H8_500 =       49;
-enum EM_IA_64 =        50;
-enum EM_MIPS_X =       51;
-enum EM_COLDFIRE =     52;
-enum EM_68HC12 =       53;
-enum EM_MMA =          54;
-enum EM_PCP =          55;
-enum EM_NCPU =         56;
-enum EM_NDR1 =         57;
-enum EM_STARCORE =     58;
-enum EM_ME16 =         59;
-enum EM_ST100 =        60;
-enum EM_TINYJ =        61;
-enum EM_X86_64 =       62;
-enum EM_AMD64 =        62;
-enum EM_PDSP =         63;
-enum EM_FX66 =         66;
-enum EM_ST9PLUS =      67;
-enum EM_ST7 =          68;
-enum EM_68HC16 =       69;
-enum EM_68HC11 =       70;
-enum EM_68HC08 =       71;
-enum EM_68HC05 =       72;
-enum EM_SVX =          73;
-enum EM_ST19 =         74;
-enum EM_VAX =          75;
-enum EM_CRIS =         76;
-enum EM_JAVELIN =      77;
-enum EM_FIREPATH =     78;
-enum EM_ZSP =          79;
-enum EM_MMIX =         80;
-enum EM_HUANY =        81;
-enum EM_PRISM =        82;
-enum EM_AVR =          83;
-enum EM_FR30 =         84;
-enum EM_D10V =         85;
-enum EM_D30V =         86;
-enum EM_V850 =         87;
-enum EM_M32R =         88;
-enum EM_MN10300 =      89;
-enum EM_MN10200 =      90;
-enum EM_PJ =           91;
-enum EM_OPENRISC =     92;
-enum EM_ARC_A5 =       93;
-enum EM_XTENSA =       94;
-enum EM_VIDEOCORE =    95;
-enum EM_TMM_GPP =      96;
-enum EM_NS32K =        97;
-enum EM_TPC =          98;
-enum EM_SNP1K =        99;
-enum EM_ST200 =       100;
-enum EM_IP2K =        101;
-enum EM_MAX =         102;
-enum EM_CR =          103;
-enum EM_F2MC16 =      104;
-enum EM_MSP430 =      105;
-enum EM_BLACKFIN =    106;
-enum EM_SE_C33 =      107;
-enum EM_SEP =         108;
-enum EM_ARCA =        109;
-enum EM_UNICORE =     110;
-enum EM_AARCH64 =     183;     /* AArch64 64-bit ARM microprocessor */
-
-/* Unofficial machine types follow */
-enum EM_AVR32  =       6317;    /* used by NetBSD/avr32 */
-enum EM_ALPHA_EXP  =  36902;   /* used by NetBSD/alpha; obsolete */
+enum EM_AVR32  =       6317;
+enum EM_ALPHA_EXP  =  36902;
 
 enum EM_486 =           6;
 enum EM_MIPS_RS4_BE =  10;
 enum EM_ALPHA_STD =    41;
-enum EM_ALPHA =    0x9026;
-
-enum SHN_UNDEF =       0;
-enum SHN_LORESERVE =   0xff00;
-enum SHN_LOPROC =      0xff00;
-enum SHN_HIPROC =      0xff1f;
-enum SHN_LOOS =        0xff20;
-enum SHN_HIOS =        0xff3f;
-enum SHN_ABS =         0xfff1;
-enum SHN_COMMON =      0xfff2;
-enum SHN_XINDEX =      0xffff;
-enum SHN_HIRESERVE =   0xffff;
 
-enum SHT_NULL =          0;
-enum SHT_PROGBITS =      1;
-enum SHT_SYMTAB =        2;
-enum SHT_STRTAB =        3;
-enum SHT_RELA =          4;
-enum SHT_HASH =          5;
-enum SHT_DYNAMIC =       6;
-enum SHT_NOTE =          7;
-enum SHT_NOBITS =        8;
-enum SHT_REL =           9;
-enum SHT_SHLIB =         10;
-enum SHT_DYNSYM =        11;
-enum SHT_INIT_ARRAY =    14;
-enum SHT_FINI_ARRAY =    15;
-enum SHT_PREINIT_ARRAY = 16;
-enum SHT_GROUP =         17;
-enum SHT_SYMTAB_SHNDX =  18;
-enum SHT_LOOS =          0x60000000;
-enum SHT_LOSUNW =        0x6ffffff4;
 enum SHT_SUNW_dof =      0x6ffffff4;
 enum SHT_SUNW_cap =      0x6ffffff5;
 enum SHT_SUNW_SIGNATURE = 0x6ffffff6;
-enum SHT_GNU_HASH =      0x6ffffff6;
-enum SHT_SUNW_ANNOTATE = 0x6ffffff7;
-enum SHT_SUNW_DEBUGSTR = 0x6ffffff8;
-enum SHT_SUNW_DEBUG =    0x6ffffff9;
-enum SHT_SUNW_move =     0x6ffffffa;
-enum SHT_SUNW_COMDAT =   0x6ffffffb;
-enum SHT_SUNW_syminfo =  0x6ffffffc;
 enum SHT_SUNW_verdef =   0x6ffffffd;
-enum SHT_GNU_verdef =    0x6ffffffd;
 enum SHT_SUNW_verneed =  0x6ffffffe;
-enum SHT_GNU_verneed =   0x6ffffffe;
 enum SHT_SUNW_versym =   0x6fffffff;
-enum SHT_GNU_versym =    0x6fffffff;
-enum SHT_HISUNW =        0x6fffffff;
-enum SHT_HIOS =          0x6fffffff;
-enum SHT_LOPROC =        0x70000000;
-enum SHT_AMD64_UNWIND =  0x70000001;
-enum SHT_ARM_EXIDX =     0x70000001;
-enum SHT_ARM_PREEMPTMAP = 0x70000002;
-enum SHT_ARM_ATTRIBUTES = 0x70000003;
-enum SHT_ARM_DEBUGOVERLAY = 0x70000004;
-enum SHT_ARM_OVERLAYSECTION = 0x70000005;
-enum SHT_MIPS_REGINFO =  0x70000006;
-enum SHT_MIPS_OPTIONS =  0x7000000d;
-enum SHT_MIPS_DWARF =    0x7000001e;
-enum SHT_HIPROC =        0x7fffffff;
-enum SHT_LOUSER =        0x80000000;
-enum SHT_HIUSER =        0x8fffffff;
 
-enum SHF_WRITE =            (1 << 0);
-enum SHF_ALLOC =            (1 << 1);
-enum SHF_EXECINSTR =        (1 << 2);
-enum SHF_MERGE =            (1 << 4);
-enum SHF_STRINGS =          (1 << 5);
-enum SHF_INFO_LINK =        (1 << 6);
-enum SHF_LINK_ORDER =       (1 << 7);
-enum SHF_OS_NONCONFORMING = (1 << 8);
-enum SHF_GROUP =            (1 << 9);
-enum SHF_TLS =              (1 << 10);
-enum SHF_MASKOS =           0x0ff00000;
-enum SHF_MASKPROC =         0xf0000000;
-
-enum PT_NULL =         0;
-enum PT_LOAD =         1;
-enum PT_DYNAMIC =      2;
-enum PT_INTERP =       3;
-enum PT_NOTE =         4;
-enum PT_SHLIB =        5;
-enum PT_PHDR =         6;
-enum PT_TLS =          7;
-enum PT_LOOS =         0x60000000;
-enum PT_SUNW_UNWIND =  0x6464e550;
-enum PT_GNU_EH_FRAME = 0x6474e550;
-enum PT_GNU_STACK =    0x6474e551;
-enum PT_GNU_RELRO =    0x6474e552;
-enum PT_LOSUNW =       0x6ffffffa;
-enum PT_SUNWBSS =      0x6ffffffa;
-enum PT_SUNWSTACK =    0x6ffffffb;
 enum PT_SUNWDTRACE =   0x6ffffffc;
 enum PT_SUNWCAP =      0x6ffffffd;
-enum PT_HISUNW =       0x6fffffff;
-enum PT_HIOS =         0x6fffffff;
-enum PT_LOPROC =       0x70000000;
-enum PT_HIPROC =       0x7fffffff;
-
-enum PF_X =            (1 << 0);
-enum PF_W =            (1 << 1);
-enum PF_R =            (1 << 2);
-enum PF_MASKOS =       0x0ff00000;
-enum PF_MASKPROC =     0xf0000000;
-
-enum PN_XNUM =         0xffff;
-
-enum DT_NULL =         0;
-enum DT_NEEDED =       1;
-enum DT_PLTRELSZ =     2;
-enum DT_PLTGOT =       3;
-enum DT_HASH =         4;
-enum DT_STRTAB =       5;
-enum DT_SYMTAB =       6;
-enum DT_RELA =         7;
-enum DT_RELASZ =       8;
-enum DT_RELAENT =      9;
-enum DT_STRSZ =        10;
-enum DT_SYMENT =       11;
-enum DT_INIT =         12;
-enum DT_FINI =         13;
-enum DT_SONAME =       14;
-enum DT_RPATH =        15;
-enum DT_SYMBOLIC =     16;
-enum DT_REL =          17;
-enum DT_RELSZ =        18;
-enum DT_RELENT =       19;
-enum DT_PLTREL =       20;
-enum DT_DEBUG =        21;
-enum DT_TEXTREL =      22;
-enum DT_JMPREL =       23;
-enum DT_BIND_NOW =     24;
-enum DT_INIT_ARRAY =   25;
-enum DT_FINI_ARRAY =   26;
-enum DT_INIT_ARRAYSZ = 27;
-enum DT_FINI_ARRAYSZ = 28;
-enum DT_RUNPATH =      29;
-enum DT_FLAGS =        30;
-enum DT_ENCODING =     32;
-enum DT_PREINIT_ARRAY = 32;
-enum DT_PREINIT_ARRAYSZ = 33;
 enum DT_MAXPOSTAGS =   34;
-enum DT_LOOS =         0x6000000d;
 enum DT_SUNW_AUXILIARY = 0x6000000d;
 enum DT_SUNW_RTLDINF = 0x6000000e;
 enum DT_SUNW_FILTER =  0x6000000f;
 enum DT_SUNW_CAP =     0x60000010;
-enum DT_HIOS =         0x6ffff000;
-enum DT_VALRNGLO =     0x6ffffd00;
-enum DT_CHECKSUM =     0x6ffffdf8;
-enum DT_PLTPADSZ =     0x6ffffdf9;
-enum DT_MOVEENT =      0x6ffffdfa;
-enum DT_MOVESZ =       0x6ffffdfb;
-enum DT_FEATURE_1 =    0x6ffffdfc;
-enum DT_POSFLAG_1 =    0x6ffffdfd;
-enum DT_SYMINSZ =      0x6ffffdfe;
-enum DT_SYMINENT =     0x6ffffdff;
-enum DT_VALRNGHI =     0x6ffffdff;
-enum DT_ADDRRNGLO =    0x6ffffe00;
-enum DT_GNU_HASH =     0x6ffffef5;
-enum DT_CONFIG =       0x6ffffefa;
-enum DT_DEPAUDIT =     0x6ffffefb;
-enum DT_AUDIT =        0x6ffffefc;
-enum DT_PLTPAD =       0x6ffffefd;
-enum DT_MOVETAB =      0x6ffffefe;
-enum DT_SYMINFO =      0x6ffffeff;
-enum DT_ADDRRNGHI =    0x6ffffeff;
-enum DT_VERSYM =       0x6ffffff0;
-enum DT_RELACOUNT =    0x6ffffff9;
-enum DT_RELCOUNT =     0x6ffffffa;
-enum DT_FLAGS_1 =      0x6ffffffb;
-enum DT_VERDEF =       0x6ffffffc;
-enum DT_VERDEFNUM =    0x6ffffffd;
-enum DT_VERNEED =      0x6ffffffe;
-enum DT_VERNEEDNUM =   0x6fffffff;
-enum DT_LOPROC =       0x70000000;
 enum DT_DEPRECATED_SPARC_REGISTER = 0x7000001;
-enum DT_AUXILIARY =    0x7ffffffd;
 enum DT_USED =         0x7ffffffe;
-enum DT_FILTER =       0x7fffffff;
-enum DT_HIPROC =       0x7fffffff;
-
-enum DF_ORIGIN =       0x00000001;
-enum DF_SYMBOLIC =     0x00000002;
-enum DF_TEXTREL =      0x00000004;
-enum DF_BIND_NOW =     0x00000008;
-enum DF_STATIC_TLS =   0x00000010;
 
 enum DF_1_BIND_NOW =   0x00000001;
-enum DF_1_GLOBAL =     0x00000002;
-enum DF_1_NODELETE =   0x00000008;
-enum DF_1_LOADFLTR =   0x00000010;
-enum DF_1_NOOPEN =     0x00000040;
-enum DF_1_NODEFLIB =   0x00000800;
 
 enum NT_PRSTATUS =     1;
 enum NT_FPREGSET =     2;
@@ -407,55 +78,19 @@ enum NT_PROCSTAT_OSREL = 14;
 enum NT_PROCSTAT_PSSTRINGS = 15;
 enum NT_PROCSTAT_AUXV = 16;
 
-enum STB_LOCAL =       0;
-enum STB_GLOBAL =      1;
-enum STB_WEAK =        2;
-enum STB_NUM =         3;
-enum STB_LOOS =        10;
-enum STB_HIOS =        12;
-enum STB_LOPROC =      13;
-enum STB_HIPROC =      15;
-
-enum STT_NOTYPE =      0;
-enum STT_OBJECT =      1;
-enum STT_FUNC =        2;
-enum STT_SECTION =     3;
-enum STT_FILE =        4;
-enum STT_COMMON =      5;
-enum STT_TLS =         6;
-enum STT_NUM =         7;
-enum STT_LOOS =        10;
-enum STT_GNU_IFUNC =   10;
-enum STT_HIOS =        12;
-enum STT_LOPROC =      13;
-enum STT_HIPROC =      15;
-
-enum STV_DEFAULT =     0;
-enum STV_INTERNAL =    1;
-enum STV_HIDDEN =      2;
-enum STV_PROTECTED =   3;
 enum STV_EXPORTED =    4;
 enum STV_SINGLETON =   5;
 enum STV_ELIMINATE =   6;
 
-enum STN_UNDEF =       0;
-
-enum VER_DEF_CURRENT = 1;
 alias VER_NDX VER_DEF_IDX;
 
-enum VER_FLG_BASE =    0x1;
-enum VER_FLG_WEAK =    0x2;
-
-enum VER_NEED_CURRENT = 1;
 enum VER_NEED_WEAK =    32768;
 enum VER_NEED_HIDDEN = VER_NDX_HIDDEN;
 alias VER_NDX VER_NEED_IDX;
 
-enum VER_NDX_LOCAL =           0;
-enum VER_NDX_GLOBAL =          1;
 enum VER_NDX_GIVEN =           2;
-
 enum VER_NDX_HIDDEN =      32768;
+
 extern (D)
 {
     auto VER_NDX(V)(V v) { return v & ~(1u << 15); }
@@ -465,395 +100,10 @@ enum CA_SUNW_NULL =    0;
 enum CA_SUNW_HW_1 =    1;
 enum CA_SUNW_SF_1 =    2;
 
-enum SYMINFO_FLG_DIRECT =      0x0001;
-enum SYMINFO_FLG_PASSTHRU =    0x0002;
-enum SYMINFO_FLG_COPY =        0x0004;
-enum SYMINFO_FLG_LAZYLOAD =    0x0008;
 enum SYMINFO_FLG_DIRECTBIND =  0x0010;
 enum SYMINFO_FLG_NOEXTDIRECT = 0x0020;
 enum SYMINFO_FLG_FILTER =      0x0002;
 enum SYMINFO_FLG_AUXILIARY =   0x0040;
 
-enum SYMINFO_BT_SELF =         0xffff;
-enum SYMINFO_BT_PARENT =       0xfffe;
 enum SYMINFO_BT_NONE =         0xfffd;
 enum SYMINFO_BT_EXTERN =       0xfffc;
-enum SYMINFO_BT_LOWRESERVE =   0xff00;
-
-enum SYMINFO_NONE =            0;
-enum SYMINFO_CURRENT =         1;
-enum SYMINFO_NUM =             2;
-
-enum R_386_NONE =               0;
-enum R_386_32 =                 1;
-enum R_386_PC32 =               2;
-enum R_386_GOT32 =              3;
-enum R_386_PLT32 =              4;
-enum R_386_COPY =               5;
-enum R_386_GLOB_DAT =           6;
-enum R_386_JMP_SLOT =           7;
-enum R_386_RELATIVE =           8;
-enum R_386_GOTOFF =             9;
-enum R_386_GOTPC =              10;
-enum R_386_TLS_TPOFF =          14;
-enum R_386_TLS_IE =             15;
-enum R_386_TLS_GOTIE =          16;
-enum R_386_TLS_LE =             17;
-enum R_386_TLS_GD =             18;
-enum R_386_TLS_LDM =            19;
-enum R_386_TLS_GD_32 =          24;
-enum R_386_TLS_GD_PUSH =        25;
-enum R_386_TLS_GD_CALL =        26;
-enum R_386_TLS_GD_POP =         27;
-enum R_386_TLS_LDM_32 =         28;
-enum R_386_TLS_LDM_PUSH =       29;
-enum R_386_TLS_LDM_CALL =       30;
-enum R_386_TLS_LDM_POP =        31;
-enum R_386_TLS_LDO_32 =         32;
-enum R_386_TLS_IE_32 =          33;
-enum R_386_TLS_LE_32 =          34;
-enum R_386_TLS_DTPMOD32 =       35;
-enum R_386_TLS_DTPOFF32 =       36;
-enum R_386_TLS_TPOFF32 =        37;
-enum R_386_IRELATIVE =          42;
-
-enum R_ARM_NONE =               0;
-enum R_ARM_PC24 =               1;
-enum R_ARM_ABS32 =              2;
-enum R_ARM_REL32 =              3;
-enum R_ARM_PC13 =               4;
-enum R_ARM_ABS16 =              5;
-enum R_ARM_ABS12 =              6;
-enum R_ARM_THM_ABS5 =           7;
-enum R_ARM_ABS8 =               8;
-enum R_ARM_SBREL32 =            9;
-enum R_ARM_THM_PC22 =           10;
-enum R_ARM_THM_PC8 =            11;
-enum R_ARM_AMP_VCALL9 =         12;
-enum R_ARM_SWI24 =              13;
-enum R_ARM_THM_SWI8 =           14;
-enum R_ARM_XPC25 =              15;
-enum R_ARM_THM_XPC22 =          16;
-enum R_ARM_TLS_DTPMOD32 =       17;
-enum R_ARM_TLS_DTPOFF32 =       18;
-enum R_ARM_TLS_TPOFF32 =        19;
-enum R_ARM_COPY =               20;
-enum R_ARM_GLOB_DAT =           21;
-enum R_ARM_JUMP_SLOT =          22;
-enum R_ARM_RELATIVE =           23;
-enum R_ARM_GOTOFF =             24;
-enum R_ARM_GOTPC =              25;
-enum R_ARM_GOT32 =              26;
-enum R_ARM_PLT32 =              27;
-enum R_ARM_GNU_VTENTRY =        100;
-enum R_ARM_GNU_VTINHERIT =      101;
-enum R_ARM_RSBREL32 =           250;
-enum R_ARM_THM_RPC22 =          251;
-enum R_ARM_RREL32 =             252;
-enum R_ARM_RABS32 =             253;
-enum R_ARM_RPC24 =              254;
-enum R_ARM_RBASE =              255;
-
-enum R_IA_64_NONE =             0;
-enum R_IA_64_IMM14 =            0x21;
-enum R_IA_64_IMM22 =            0x22;
-enum R_IA_64_IMM64 =            0x23;
-enum R_IA_64_DIR32MSB =         0x24;
-enum R_IA_64_DIR32LSB =         0x25;
-enum R_IA_64_DIR64MSB =         0x26;
-enum R_IA_64_DIR64LSB =         0x27;
-enum R_IA_64_GPREL22 =          0x2a;
-enum R_IA_64_GPREL64I =         0x2b;
-enum R_IA_64_GPREL32MSB =       0x2c;
-enum R_IA_64_GPREL32LSB =       0x2d;
-enum R_IA_64_GPREL64MSB =       0x2e;
-enum R_IA_64_GPREL64LSB =       0x2f;
-enum R_IA_64_LTOFF22 =          0x32;
-enum R_IA_64_LTOFF64I =         0x33;
-enum R_IA_64_PLTOFF22 =         0x3a;
-enum R_IA_64_PLTOFF64I =        0x3b;
-enum R_IA_64_PLTOFF64MSB =      0x3e;
-enum R_IA_64_PLTOFF64LSB =      0x3f;
-enum R_IA_64_FPTR64I =          0x43;
-enum R_IA_64_FPTR32MSB =        0x44;
-enum R_IA_64_FPTR32LSB =        0x45;
-enum R_IA_64_FPTR64MSB =        0x46;
-enum R_IA_64_FPTR64LSB =        0x47;
-enum R_IA_64_PCREL60B =         0x48;
-enum R_IA_64_PCREL21B =         0x49;
-enum R_IA_64_PCREL21M =         0x4a;
-enum R_IA_64_PCREL21F =         0x4b;
-enum R_IA_64_PCREL32MSB =       0x4c;
-enum R_IA_64_PCREL32LSB =       0x4d;
-enum R_IA_64_PCREL64MSB =       0x4e;
-enum R_IA_64_PCREL64LSB =       0x4f;
-enum R_IA_64_LTOFF_FPTR22 =     0x52;
-enum R_IA_64_LTOFF_FPTR64I =    0x53;
-enum R_IA_64_LTOFF_FPTR32MSB =  0x54;
-enum R_IA_64_LTOFF_FPTR32LSB =  0x55;
-enum R_IA_64_LTOFF_FPTR64MSB =  0x56;
-enum R_IA_64_LTOFF_FPTR64LSB =  0x57;
-enum R_IA_64_SEGREL32MSB =      0x5c;
-enum R_IA_64_SEGREL32LSB =      0x5d;
-enum R_IA_64_SEGREL64MSB =      0x5e;
-enum R_IA_64_SEGREL64LSB =      0x5f;
-enum R_IA_64_SECREL32MSB =      0x64;
-enum R_IA_64_SECREL32LSB =      0x65;
-enum R_IA_64_SECREL64MSB =      0x66;
-enum R_IA_64_SECREL64LSB =      0x67;
-enum R_IA_64_REL32MSB =         0x6c;
-enum R_IA_64_REL32LSB =         0x6d;
-enum R_IA_64_REL64MSB =         0x6e;
-enum R_IA_64_REL64LSB =         0x6f;
-enum R_IA_64_LTV32MSB =         0x74;
-enum R_IA_64_LTV32LSB =         0x75;
-enum R_IA_64_LTV64MSB =         0x76;
-enum R_IA_64_LTV64LSB =         0x77;
-enum R_IA_64_PCREL21BI =        0x79;
-enum R_IA_64_PCREL22 =          0x7a;
-enum R_IA_64_PCREL64I =         0x7b;
-enum R_IA_64_IPLTMSB =          0x80;
-enum R_IA_64_IPLTLSB =          0x81;
-enum R_IA_64_SUB =              0x85;
-enum R_IA_64_LTOFF22X =         0x86;
-enum R_IA_64_LDXMOV =           0x87;
-enum R_IA_64_TPREL14 =          0x91;
-enum R_IA_64_TPREL22 =          0x92;
-enum R_IA_64_TPREL64I =         0x93;
-enum R_IA_64_TPREL64MSB =       0x96;
-enum R_IA_64_TPREL64LSB =       0x97;
-enum R_IA_64_LTOFF_TPREL22 =    0x9a;
-enum R_IA_64_DTPMOD64MSB =      0xa6;
-enum R_IA_64_DTPMOD64LSB =      0xa7;
-enum R_IA_64_LTOFF_DTPMOD22 =   0xaa;
-enum R_IA_64_DTPREL14 =         0xb1;
-enum R_IA_64_DTPREL22 =         0xb2;
-enum R_IA_64_DTPREL64I =        0xb3;
-enum R_IA_64_DTPREL32MSB =      0xb4;
-enum R_IA_64_DTPREL32LSB =      0xb5;
-enum R_IA_64_DTPREL64MSB =      0xb6;
-enum R_IA_64_DTPREL64LSB =      0xb7;
-enum R_IA_64_LTOFF_DTPREL22 =   0xba;
-
-enum R_MIPS_NONE =              0;
-enum R_MIPS_16 =                1;
-enum R_MIPS_32 =                2;
-enum R_MIPS_REL32 =             3;
-enum R_MIPS_26 =                4;
-enum R_MIPS_HI16 =              5;
-enum R_MIPS_LO16 =              6;
-enum R_MIPS_GPREL16 =           7;
-enum R_MIPS_LITERAL =           8;
-enum R_MIPS_GOT16 =             9;
-enum R_MIPS_PC16 =              10;
-enum R_MIPS_CALL16 =            11;
-enum R_MIPS_GPREL32 =           12;
-enum R_MIPS_GOTHI16 =           21;
-enum R_MIPS_GOTLO16 =           22;
-enum R_MIPS_CALLHI16 =          30;
-enum R_MIPS_CALLLO16 =          31;
-
-enum R_PPC_NONE =               0;
-enum R_PPC_ADDR32 =             1;
-enum R_PPC_ADDR24 =             2;
-enum R_PPC_ADDR16 =             3;
-enum R_PPC_ADDR16_LO =          4;
-enum R_PPC_ADDR16_HI =          5;
-enum R_PPC_ADDR16_HA =          6;
-enum R_PPC_ADDR14 =             7;
-enum R_PPC_ADDR14_BRTAKEN =     8;
-enum R_PPC_ADDR14_BRNTAKEN =    9;
-enum R_PPC_REL24 =              10;
-enum R_PPC_REL14 =              11;
-enum R_PPC_REL14_BRTAKEN =      12;
-enum R_PPC_REL14_BRNTAKEN =     13;
-enum R_PPC_GOT16 =              14;
-enum R_PPC_GOT16_LO =           15;
-enum R_PPC_GOT16_HI =           16;
-enum R_PPC_GOT16_HA =           17;
-enum R_PPC_PLTREL24 =           18;
-enum R_PPC_COPY =               19;
-enum R_PPC_GLOB_DAT =           20;
-enum R_PPC_JMP_SLOT =           21;
-enum R_PPC_RELATIVE =           22;
-enum R_PPC_LOCAL24PC =          23;
-enum R_PPC_UADDR32 =            24;
-enum R_PPC_UADDR16 =            25;
-enum R_PPC_REL32 =              26;
-enum R_PPC_PLT32 =              27;
-enum R_PPC_PLTREL32 =           28;
-enum R_PPC_PLT16_LO =           29;
-enum R_PPC_PLT16_HI =           30;
-enum R_PPC_PLT16_HA =           31;
-enum R_PPC_SDAREL16 =           32;
-enum R_PPC_SECTOFF =            33;
-enum R_PPC_SECTOFF_LO =         34;
-enum R_PPC_SECTOFF_HI =         35;
-enum R_PPC_SECTOFF_HA =         36;
-
-enum R_PPC64_ADDR64 =           38;
-enum R_PPC64_ADDR16_HIGHER =    39;
-enum R_PPC64_ADDR16_HIGHERA =   40;
-enum R_PPC64_ADDR16_HIGHEST =   41;
-enum R_PPC64_ADDR16_HIGHESTA =  42;
-enum R_PPC64_UADDR64 =          43;
-enum R_PPC64_REL64 =            44;
-enum R_PPC64_PLT64 =            45;
-enum R_PPC64_PLTREL64 =         46;
-enum R_PPC64_TOC16 =            47;
-enum R_PPC64_TOC16_LO =         48;
-enum R_PPC64_TOC16_HI =         49;
-enum R_PPC64_TOC16_HA =         50;
-enum R_PPC64_TOC =              51;
-enum R_PPC64_DTPMOD64 =         68;
-enum R_PPC64_TPREL64 =          73;
-enum R_PPC64_DTPREL64 =         78;
-
-enum R_PPC_TLS =                67;
-enum R_PPC_DTPMOD32 =           68;
-enum R_PPC_TPREL16 =            69;
-enum R_PPC_TPREL16_LO =         70;
-enum R_PPC_TPREL16_HI =         71;
-enum R_PPC_TPREL16_HA =         72;
-enum R_PPC_TPREL32 =            73;
-enum R_PPC_DTPREL16 =           74;
-enum R_PPC_DTPREL16_LO =        75;
-enum R_PPC_DTPREL16_HI =        76;
-enum R_PPC_DTPREL16_HA =        77;
-enum R_PPC_DTPREL32 =           78;
-enum R_PPC_GOT_TLSGD16 =        79;
-enum R_PPC_GOT_TLSGD16_LO =     80;
-enum R_PPC_GOT_TLSGD16_HI =     81;
-enum R_PPC_GOT_TLSGD16_HA =     82;
-enum R_PPC_GOT_TLSLD16 =        83;
-enum R_PPC_GOT_TLSLD16_LO =     84;
-enum R_PPC_GOT_TLSLD16_HI =     85;
-enum R_PPC_GOT_TLSLD16_HA =     86;
-enum R_PPC_GOT_TPREL16 =        87;
-enum R_PPC_GOT_TPREL16_LO =     88;
-enum R_PPC_GOT_TPREL16_HI =     89;
-enum R_PPC_GOT_TPREL16_HA =     90;
-
-enum R_PPC_EMB_NADDR32 =        101;
-enum R_PPC_EMB_NADDR16 =        102;
-enum R_PPC_EMB_NADDR16_LO =     103;
-enum R_PPC_EMB_NADDR16_HI =     104;
-enum R_PPC_EMB_NADDR16_HA =     105;
-enum R_PPC_EMB_SDAI16 =         106;
-enum R_PPC_EMB_SDA2I16 =        107;
-enum R_PPC_EMB_SDA2REL =        108;
-enum R_PPC_EMB_SDA21 =          109;
-enum R_PPC_EMB_MRKREF =         110;
-enum R_PPC_EMB_RELSEC16 =       111;
-enum R_PPC_EMB_RELST_LO =       112;
-enum R_PPC_EMB_RELST_HI =       113;
-enum R_PPC_EMB_RELST_HA =       114;
-enum R_PPC_EMB_BIT_FLD =        115;
-enum R_PPC_EMB_RELSDA =         116;
-
-enum R_SPARC_NONE =             0;
-enum R_SPARC_8 =                1;
-enum R_SPARC_16 =               2;
-enum R_SPARC_32 =               3;
-enum R_SPARC_DISP8 =            4;
-enum R_SPARC_DISP16 =           5;
-enum R_SPARC_DISP32 =           6;
-enum R_SPARC_WDISP30 =          7;
-enum R_SPARC_WDISP22 =          8;
-enum R_SPARC_HI22 =             9;
-enum R_SPARC_22 =               10;
-enum R_SPARC_13 =               11;
-enum R_SPARC_LO10 =             12;
-enum R_SPARC_GOT10 =            13;
-enum R_SPARC_GOT13 =            14;
-enum R_SPARC_GOT22 =            15;
-enum R_SPARC_PC10 =             16;
-enum R_SPARC_PC22 =             17;
-enum R_SPARC_WPLT30 =           18;
-enum R_SPARC_COPY =             19;
-enum R_SPARC_GLOB_DAT =         20;
-enum R_SPARC_JMP_SLOT =         21;
-enum R_SPARC_RELATIVE =         22;
-enum R_SPARC_UA32 =             23;
-enum R_SPARC_PLT32 =            24;
-enum R_SPARC_HIPLT22 =          25;
-enum R_SPARC_LOPLT10 =          26;
-enum R_SPARC_PCPLT32 =          27;
-enum R_SPARC_PCPLT22 =          28;
-enum R_SPARC_PCPLT10 =          29;
-enum R_SPARC_10 =               30;
-enum R_SPARC_11 =               31;
-enum R_SPARC_64 =               32;
-enum R_SPARC_OLO10 =            33;
-enum R_SPARC_HH22 =             34;
-enum R_SPARC_HM10 =             35;
-enum R_SPARC_LM22 =             36;
-enum R_SPARC_PC_HH22 =          37;
-enum R_SPARC_PC_HM10 =          38;
-enum R_SPARC_PC_LM22 =          39;
-enum R_SPARC_WDISP16 =          40;
-enum R_SPARC_WDISP19 =          41;
-enum R_SPARC_GLOB_JMP =         42;
-enum R_SPARC_7 =                43;
-enum R_SPARC_5 =                44;
-enum R_SPARC_6 =                45;
-enum R_SPARC_DISP64 =           46;
-enum R_SPARC_PLT64 =            47;
-enum R_SPARC_HIX22 =            48;
-enum R_SPARC_LOX10 =            49;
-enum R_SPARC_H44 =              50;
-enum R_SPARC_M44 =              51;
-enum R_SPARC_L44 =              52;
-enum R_SPARC_REGISTER =         53;
-enum R_SPARC_UA64 =             54;
-enum R_SPARC_UA16 =             55;
-enum R_SPARC_TLS_GD_HI22 =      56;
-enum R_SPARC_TLS_GD_LO10 =      57;
-enum R_SPARC_TLS_GD_ADD =       58;
-enum R_SPARC_TLS_GD_CALL =      59;
-enum R_SPARC_TLS_LDM_HI22 =     60;
-enum R_SPARC_TLS_LDM_LO10 =     61;
-enum R_SPARC_TLS_LDM_ADD =      62;
-enum R_SPARC_TLS_LDM_CALL =     63;
-enum R_SPARC_TLS_LDO_HIX22 =    64;
-enum R_SPARC_TLS_LDO_LOX10 =    65;
-enum R_SPARC_TLS_LDO_ADD =      66;
-enum R_SPARC_TLS_IE_HI22 =      67;
-enum R_SPARC_TLS_IE_LO10 =      68;
-enum R_SPARC_TLS_IE_LD =        69;
-enum R_SPARC_TLS_IE_LDX =       70;
-enum R_SPARC_TLS_IE_ADD =       71;
-enum R_SPARC_TLS_LE_HIX22 =     72;
-enum R_SPARC_TLS_LE_LOX10 =     73;
-enum R_SPARC_TLS_DTPMOD32 =     74;
-enum R_SPARC_TLS_DTPMOD64 =     75;
-enum R_SPARC_TLS_DTPOFF32 =     76;
-enum R_SPARC_TLS_DTPOFF64 =     77;
-enum R_SPARC_TLS_TPOFF32 =      78;
-enum R_SPARC_TLS_TPOFF64 =      79;
-
-enum R_X86_64_NONE =            0;
-enum R_X86_64_64 =              1;
-enum R_X86_64_PC32 =            2;
-enum R_X86_64_GOT32 =           3;
-enum R_X86_64_PLT32 =           4;
-enum R_X86_64_COPY =            5;
-enum R_X86_64_GLOB_DAT =        6;
-enum R_X86_64_JMP_SLOT =        7;
-enum R_X86_64_RELATIVE =        8;
-enum R_X86_64_GOTPCREL =        9;
-enum R_X86_64_32 =              10;
-enum R_X86_64_32S =             11;
-enum R_X86_64_16 =              12;
-enum R_X86_64_PC16 =            13;
-enum R_X86_64_8 =               14;
-enum R_X86_64_PC8 =             15;
-enum R_X86_64_DTPMOD64 =        16;
-enum R_X86_64_DTPOFF64 =        17;
-enum R_X86_64_TPOFF64 =         18;
-enum R_X86_64_TLSGD =           19;
-enum R_X86_64_TLSLD =           20;
-enum R_X86_64_DTPOFF32 =        21;
-enum R_X86_64_GOTTPOFF =        22;
-enum R_X86_64_TPOFF32 =         23;
-enum R_X86_64_IRELATIVE =       37;
index dae977a632e5980053e9d9ccb6caec2c454e24f0..342282b857b73d38b19c6e41ccc91486c7d01533 100644 (file)
 module core.sys.openbsd.sys.elf32;
 
 version (OpenBSD):
-
 extern (C):
+pure:
+nothrow:
 
 import core.stdc.stdint;
 public import core.sys.openbsd.sys.elf_common;
 
-alias uint16_t Elf32_Half;
-alias uint32_t Elf32_Word;
-alias int32_t  Elf32_Sword;
 alias uint64_t Elf32_Lword;
-alias uint32_t Elf32_Addr;
-alias uint32_t Elf32_Off;
 alias Elf32_Word Elf32_Hashelt;
 alias Elf32_Word Elf32_Size;
 alias Elf32_Sword Elf32_Ssize;
 
-struct Elf32_Ehdr
-{
-    char[EI_NIDENT] e_ident = 0;
-    Elf32_Half    e_type;
-    Elf32_Half    e_machine;
-    Elf32_Word    e_version;
-    Elf32_Addr    e_entry;
-    Elf32_Off     e_phoff;
-    Elf32_Off     e_shoff;
-    Elf32_Word    e_flags;
-    Elf32_Half    e_ehsize;
-    Elf32_Half    e_phentsize;
-    Elf32_Half    e_phnum;
-    Elf32_Half    e_shentsize;
-    Elf32_Half    e_shnum;
-    Elf32_Half    e_shstrndx;
-}
-
-struct Elf32_Shdr
-{
-    Elf32_Word    sh_name;
-    Elf32_Word    sh_type;
-    Elf32_Word    sh_flags;
-    Elf32_Addr    sh_addr;
-    Elf32_Off     sh_offset;
-    Elf32_Word    sh_size;
-    Elf32_Word    sh_link;
-    Elf32_Word    sh_info;
-    Elf32_Word    sh_addralign;
-    Elf32_Word    sh_entsize;
-}
-
-struct Elf32_Phdr
-{
-    Elf32_Word    p_type;
-    Elf32_Off     p_offset;
-    Elf32_Addr    p_vaddr;
-    Elf32_Addr    p_paddr;
-    Elf32_Word    p_filesz;
-    Elf32_Word    p_memsz;
-    Elf32_Word    p_flags;
-    Elf32_Word    p_align;
-}
-
-struct Elf32_Dyn
-{
-  Elf32_Sword   d_tag;
-  union _d_un
-  {
-      Elf32_Word d_val;
-      Elf32_Addr d_ptr;
-  } _d_un d_un;
-}
-
-struct Elf32_Rel
-{
-    Elf32_Addr    r_offset;
-    Elf32_Word    r_info;
-}
-
-struct Elf32_Rela
-{
-    Elf32_Addr    r_offset;
-    Elf32_Word    r_info;
-    Elf32_Sword   r_addend;
-}
-
-extern (D) pure @safe
-{
-    auto ELF32_R_SYM(V)(V val) { return val >> 8; }
-    auto ELF32_R_TYPE(V)(V val) { return val & 0xff; }
-    auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); }
-}
-
 alias Elf_Note Elf32_Nhdr;
 
-struct Elf32_Move
-{
-    Elf32_Lword   m_value;
-    Elf32_Word    m_info;
-    Elf32_Word    m_poffset;
-    Elf32_Half    m_repeat;
-    Elf32_Half    m_stride;
-}
-
-extern (D) pure
-{
-    auto ELF32_M_SYM(I)(I info) @safe { return info >> 8; }
-    auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; }
-    auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; }
-}
-
 struct Elf32_Cap
 {
     Elf32_Word    c_tag;
@@ -125,63 +31,7 @@ struct Elf32_Cap
     } _c_un c_un;
 }
 
-struct Elf32_Sym
-{
-    Elf32_Word    st_name;
-    Elf32_Addr    st_value;
-    Elf32_Word    st_size;
-    ubyte st_info;
-    ubyte st_other;
-    Elf32_Half st_shndx;
-}
-
-extern (D) pure
-{
-    auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
-    auto ELF32_ST_TYPE(T)(T val) @safe { return val & 0xf; }
-    auto ELF32_ST_INFO(B, T)(B bind, T type) @safe { return (bind << 4) + (type & 0xf); }
-    auto ELF32_ST_VISIBILITY(O)(O o) @safe { return o & 0x03; }
-}
-
-struct Elf32_Verdef
-{
-    Elf32_Half    vd_version;
-    Elf32_Half    vd_flags;
-    Elf32_Half    vd_ndx;
-    Elf32_Half    vd_cnt;
-    Elf32_Word    vd_hash;
-    Elf32_Word    vd_aux;
-    Elf32_Word    vd_next;
-}
-
-struct Elf32_Verdaux
-{
-    Elf32_Word    vda_name;
-    Elf32_Word    vda_next;
-}
-
-struct Elf32_Verneed
-{
-    Elf32_Half    vn_version;
-    Elf32_Half    vn_cnt;
-    Elf32_Word    vn_file;
-    Elf32_Word    vn_aux;
-    Elf32_Word    vn_next;
-}
-
-struct Elf32_Vernaux
-{
-    Elf32_Word    vna_hash;
-    Elf32_Half    vna_flags;
-    Elf32_Half    vna_other;
-    Elf32_Word    vna_name;
-    Elf32_Word    vna_next;
-}
-
-alias Elf32_Half Elf32_Versym;
-
-struct Elf32_Syminfo
+extern (D)
 {
-    Elf32_Half si_boundto;
-    Elf32_Half si_flags;
+    auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; }
 }
index e26a5fc6e3cf8b9a0d0e0647a7245117b6a533ae..b76d669b3049e54bc070fa356e051593b48d3c15 100644 (file)
@@ -7,97 +7,20 @@
 module core.sys.openbsd.sys.elf64;
 
 version (OpenBSD):
-
 extern (C):
+pure:
+nothrow:
 
 import core.stdc.stdint;
 public import core.sys.openbsd.sys.elf_common;
 
-alias uint16_t Elf64_Half;
-alias uint32_t Elf64_Word;
-alias int32_t  Elf64_Sword;
 alias uint64_t Elf64_Lword;
-alias uint64_t Elf64_Xword;
-alias int64_t  Elf64_Sxword;
-alias uint64_t Elf64_Addr;
-alias uint64_t Elf64_Off;
 alias Elf64_Word Elf64_Hashelt;
 alias Elf64_Xword Elf64_Size;
 alias Elf64_Sxword Elf64_Ssize;
 
-struct Elf64_Ehdr
-{
-    char[EI_NIDENT] e_ident = 0;
-    Elf64_Half    e_type;
-    Elf64_Half    e_machine;
-    Elf64_Word    e_version;
-    Elf64_Addr    e_entry;
-    Elf64_Off     e_phoff;
-    Elf64_Off     e_shoff;
-    Elf64_Word    e_flags;
-    Elf64_Half    e_ehsize;
-    Elf64_Half    e_phentsize;
-    Elf64_Half    e_phnum;
-    Elf64_Half    e_shentsize;
-    Elf64_Half    e_shnum;
-    Elf64_Half    e_shstrndx;
-}
-
-struct Elf64_Shdr
-{
-    Elf64_Word    sh_name;
-    Elf64_Word    sh_type;
-    Elf64_Xword   sh_flags;
-    Elf64_Addr    sh_addr;
-    Elf64_Off     sh_offset;
-    Elf64_Xword   sh_size;
-    Elf64_Word    sh_link;
-    Elf64_Word    sh_info;
-    Elf64_Xword   sh_addralign;
-    Elf64_Xword   sh_entsize;
-}
-
-struct Elf64_Phdr
-{
-    Elf64_Word    p_type;
-    Elf64_Word    p_flags;
-    Elf64_Off     p_offset;
-    Elf64_Addr    p_vaddr;
-    Elf64_Addr    p_paddr;
-    Elf64_Xword   p_filesz;
-    Elf64_Xword   p_memsz;
-    Elf64_Xword   p_align;
-}
-
-struct Elf64_Dyn
-{
-  Elf64_Sxword  d_tag;
-  union _d_un
-  {
-      Elf64_Xword d_val;
-      Elf64_Addr d_ptr;
-  } _d_un d_un;
-}
-
-struct Elf64_Rel
-{
-    Elf64_Addr    r_offset;
-    Elf64_Xword   r_info;
-}
-
-struct Elf64_Rela
-{
-    Elf64_Addr    r_offset;
-    Elf64_Xword   r_info;
-    Elf64_Sxword  r_addend;
-}
-
 extern (D) pure
 {
-    auto ELF64_R_SYM(I)(I i) @safe { return i >> 32; }
-    auto ELF64_R_TYPE(I)(I i) @safe { return i & 0xffffffff; }
-    auto ELF64_R_INFO(S, T)(S sym, T type) @safe { return (sym << 32) + (type & 0xffffffff); }
-
     auto ELF64_R_TYPE_DATA(I)(I i) { return (cast(Elf64_Xword) i << 32) >> 40; }
     auto ELF64_R_TYPE_ID(I)(I i) { return (cast(Elf64_Xword) i << 56 ) >> 56; }
     auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; }
@@ -105,22 +28,6 @@ extern (D) pure
 
 alias Elf_Note Elf64_Nhdr;
 
-struct Elf64_Move
-{
-    Elf64_Lword   m_value;
-    Elf64_Xword   m_info;
-    Elf64_Xword   m_poffset;
-    Elf64_Half    m_repeat;
-    Elf64_Half    m_stride;
-}
-
-extern (D) pure
-{
-    auto ELF64_M_SYM(I)(I info) @safe { return info >> 8; }
-    auto ELF64_M_SIZE(I)(I info) { return cast(ubyte)info; }
-    auto ELF64_M_INFO(S, SZ)(S sym, SZ size) @safe { return (sym << 8) + cast(ubyte)size; }
-}
-
 struct Elf64_Cap
 {
     Elf64_Xword   c_tag;
@@ -131,63 +38,7 @@ struct Elf64_Cap
     } _c_un c_un;
 }
 
-struct Elf64_Sym
-{
-    Elf64_Word    st_name;
-    ubyte st_info;
-    ubyte st_other;
-    Elf64_Half st_shndx;
-    Elf64_Addr    st_value;
-    Elf64_Xword   st_size;
-}
-
-extern (D) pure
-{
-    auto ELF64_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
-    auto ELF64_ST_TYPE(T)(T val) @safe { return val & 0xf; }
-    auto ELF64_ST_INFO(B, T)(B bind, T type) @safe { return (bind << 4) + (type & 0xf); }
-    auto ELF64_ST_VISIBILITY(O)(O o) @safe { return o & 0x03; }
-}
-
-struct Elf64_Verdef
-{
-    Elf64_Half    vd_version;
-    Elf64_Half    vd_flags;
-    Elf64_Half    vd_ndx;
-    Elf64_Half    vd_cnt;
-    Elf64_Word    vd_hash;
-    Elf64_Word    vd_aux;
-    Elf64_Word    vd_next;
-}
-
-struct Elf64_Verdaux
-{
-    Elf64_Word    vda_name;
-    Elf64_Word    vda_next;
-}
-
-struct Elf64_Verneed
-{
-    Elf64_Half    vn_version;
-    Elf64_Half    vn_cnt;
-    Elf64_Word    vn_file;
-    Elf64_Word    vn_aux;
-    Elf64_Word    vn_next;
-}
-
-struct Elf64_Vernaux
-{
-    Elf64_Word    vna_hash;
-    Elf64_Half    vna_flags;
-    Elf64_Half    vna_other;
-    Elf64_Word    vna_name;
-    Elf64_Word    vna_next;
-}
-
-alias Elf64_Half Elf64_Versym;
-
-struct Elf64_Syminfo
+extern (D)
 {
-    Elf64_Half si_boundto;
-    Elf64_Half si_flags;
+    auto ELF64_ST_VISIBILITY(O)(O o) { return o & 0x03; }
 }
index bcd2701ae82e4e6d9b0933e6894798e04a7117b3..4812e1f04dd85b8869655d56a2db30b469cd3f11 100644 (file)
@@ -7,10 +7,12 @@
 module core.sys.openbsd.sys.elf_common;
 
 version (OpenBSD):
-
 extern (C):
+pure:
+nothrow:
 
 import core.stdc.stdint;
+public import core.sys.elf;
 
 struct Elf_Note
 {
@@ -27,60 +29,7 @@ struct Elf_GNU_Hash_Header
     uint32_t      gh_shift2;
 }
 
-enum EI_MAG0 =         0;
-enum EI_MAG1 =         1;
-enum EI_MAG2 =         2;
-enum EI_MAG3 =         3;
-enum EI_CLASS =        4;
-enum EI_DATA =         5;
-enum EI_VERSION =      6;
-enum EI_OSABI =        7;
-enum EI_ABIVERSION =   8;
 enum OLD_EI_BRAND =    8;
-enum EI_PAD =          9;
-enum EI_NIDENT =       16;
-
-enum ELFMAG0 =         0x7f;
-enum ELFMAG1 =         'E';
-enum ELFMAG2 =         'L';
-enum ELFMAG3 =         'F';
-enum ELFMAG =          "\177ELF";
-enum SELFMAG =         4;
-
-enum EV_NONE =         0;
-enum EV_CURRENT =      1;
-
-enum ELFCLASSNONE =    0;
-enum ELFCLASS32 =      1;
-enum ELFCLASS64 =      2;
-
-enum ELFDATANONE =     0;
-enum ELFDATA2LSB =     1;
-enum ELFDATA2MSB =     2;
-
-enum ELFOSABI_NONE =           0;
-enum ELFOSABI_SYSV =           0;
-enum ELFOSABI_HPUX =           1;
-enum ELFOSABI_NETBSD =         2;
-enum ELFOSABI_LINUX =          3;
-enum ELFOSABI_HURD  =          4;
-enum ELFOSABI_86OPEN =         5;
-enum ELFOSABI_SOLARIS =        6;
-enum ELFOSABI_AIX =            7;
-enum ELFOSABI_MONTEREY =       7;
-enum ELFOSABI_IRIX =           8;
-enum ELFOSABI_FREEBSD =        9;
-enum ELFOSABI_TRU64 =          10;
-enum ELFOSABI_MODESTO =        11;
-enum ELFOSABI_OPENBSD =        12;
-enum ELFOSABI_OPENVMS =        13;
-enum ELFOSABI_NSK =            14;
-enum ELFOSABI_AROS =           15;
-enum ELFOSABI_ARM =            97;
-enum ELFOSABI_STANDALONE =     255;
-
-// just a pointer
-enum ELFOSABI_DRAGONFLYBSD =   ELFOSABI_NONE;
 
 extern (D) pure @safe
 {
@@ -90,587 +39,44 @@ extern (D) pure @safe
                                     ehdr.e_ident[EI_MAG3] == ELFMAG3; }
 }
 
-enum ET_NONE =         0;
-enum ET_REL =          1;
-enum ET_EXEC =         2;
-enum ET_DYN =          3;
-enum ET_CORE =         4;
-enum ET_LOOS =         0xfe00;
-enum ET_HIOS =         0xfeff;
-enum ET_LOPROC =       0xff00;
-enum ET_HIPROC =       0xffff;
-
-enum EM_NONE =          0;
-enum EM_M32 =           1;
-enum EM_SPARC =         2;
-enum EM_386 =           3;
-enum EM_68K =           4;
-enum EM_88K =           5;
-enum EM_860 =           7;
-enum EM_MIPS =          8;
-enum EM_S370 =          9;
-enum EM_MIPS_RS3_LE =  10;
-enum EM_PARISC =       15;
-enum EM_VPP500 =       17;
-enum EM_SPARC32PLUS =  18;
-enum EM_960 =          19;
-enum EM_PPC =          20;
-enum EM_PPC64 =        21;
-enum EM_S390 =         22;
-enum EM_V800 =         36;
-enum EM_FR20 =         37;
-enum EM_RH32 =         38;
-enum EM_RCE =          39;
-enum EM_ARM =          40;
-enum EM_SH =           42;
-enum EM_SPARCV9 =      43;
-enum EM_TRICORE =      44;
-enum EM_ARC =          45;
-enum EM_H8_300 =       46;
-enum EM_H8_300H =      47;
-enum EM_H8S =          48;
-enum EM_H8_500 =       49;
-enum EM_IA_64 =        50;
-enum EM_MIPS_X =       51;
-enum EM_COLDFIRE =     52;
-enum EM_68HC12 =       53;
-enum EM_MMA =          54;
-enum EM_PCP =          55;
-enum EM_NCPU =         56;
-enum EM_NDR1 =         57;
-enum EM_STARCORE =     58;
-enum EM_ME16 =         59;
-enum EM_ST100 =        60;
-enum EM_TINYJ =        61;
-enum EM_X86_64 =       62;
-enum EM_AMD64 =        62;
-enum EM_PDSP =         63;
-enum EM_FX66 =         66;
-enum EM_ST9PLUS =      67;
-enum EM_ST7 =          68;
-enum EM_68HC16 =       69;
-enum EM_68HC11 =       70;
-enum EM_68HC08 =       71;
-enum EM_68HC05 =       72;
-enum EM_SVX =          73;
-enum EM_ST19 =         74;
-enum EM_VAX =          75;
-enum EM_CRIS =         76;
-enum EM_JAVELIN =      77;
-enum EM_FIREPATH =     78;
-enum EM_ZSP =          79;
-enum EM_MMIX =         80;
-enum EM_HUANY =        81;
-enum EM_PRISM =        82;
-enum EM_AVR =          83;
-enum EM_FR30 =         84;
-enum EM_D10V =         85;
-enum EM_D30V =         86;
-enum EM_V850 =         87;
-enum EM_M32R =         88;
-enum EM_MN10300 =      89;
-enum EM_MN10200 =      90;
-enum EM_PJ =           91;
-enum EM_OPENRISC =     92;
-enum EM_ARC_A5 =       93;
-enum EM_XTENSA =       94;
-enum EM_VIDEOCORE =    95;
-enum EM_TMM_GPP =      96;
-enum EM_NS32K =        97;
-enum EM_TPC =          98;
-enum EM_SNP1K =        99;
-enum EM_ST200 =       100;
-enum EM_IP2K =        101;
-enum EM_MAX =         102;
-enum EM_CR =          103;
-enum EM_F2MC16 =      104;
-enum EM_MSP430 =      105;
-enum EM_BLACKFIN =    106;
-enum EM_SE_C33 =      107;
-enum EM_SEP =         108;
-enum EM_ARCA =        109;
-enum EM_UNICORE =     110;
-enum EM_DXP =         112;
-enum EM_ALTERA_NIOS2 =113;
-enum EM_CRX =         114;
-enum EM_XGATE =       115;
-enum EM_C166  =       116;
-enum EM_M16C  =       117;
-enum EM_DSPIC30F =    118;
-enum EM_CE =          119;
-enum EM_M32C  =       120;
-enum EM_res121 =      121;
-enum EM_res122 =      122;
-enum EM_res123 =      123;
-enum EM_res124 =      124;
-enum EM_res125 =      125;
-enum EM_res126 =      126;
-enum EM_res127 =      127;
-enum EM_res128 =      128;
-enum EM_res129 =      129;
-enum EM_res130 =      130;
-enum EM_TSK3000 =     131;
-enum EM_RS08  =       132;
-enum EM_res133 =      133;
-enum EM_ECOG2 =       134;
-enum EM_SCORE =       135;
-enum EM_SCORE7 =      135;
-enum EM_DSP24 =       136;
-enum EM_VIDEOCORE3 =  137;
-enum EM_LATTICEMICO32 = 138;
-enum EM_SE_C17 =      139;
-enum EM_TI_C6000 =    140;
-enum EM_TI_C2000 =    141;
-enum EM_TI_C5500 =    142;
-enum EM_res143 =      143;
-enum EM_res144 =      144;
-enum EM_res145 =      145;
-enum EM_res146 =      146;
-enum EM_res147 =      147;
-enum EM_res148 =      148;
-enum EM_res149 =      149;
-enum EM_res150 =      150;
-enum EM_res151 =      151;
-enum EM_res152 =      152;
-enum EM_res153 =      153;
-enum EM_res154 =      154;
-enum EM_res155 =      155;
-enum EM_res156 =      156;
-enum EM_res157 =      157;
-enum EM_res158 =      158;
-enum EM_res159 =      159;
-enum EM_MMDSP_PLUS =  160;
-enum EM_CYPRESS_M8C = 161;
-enum EM_R32C  =       162;
-enum EM_TRIMEDIA =    163;
-enum EM_QDSP6 =       164;
-enum EM_8051  =       165;
-enum EM_STXP7X =      166;
-enum EM_NDS32 =       167;
-enum EM_ECOG1 =       168;
-enum EM_ECOG1X =      168;
-enum EM_MAXQ30 =      169;
-enum EM_XIMO16 =      170;
-enum EM_MANIK =       171;
-enum EM_CRAYNV2 =     172;
-enum EM_RX =          173;
-enum EM_METAG =       174;
-enum EM_MCST_ELBRUS = 175;
-enum EM_ECOG16 =      176;
-enum EM_CR16  =       177;
-enum EM_ETPU  =       178;
-enum EM_SLE9X =       179;
-enum EM_L1OM  =       180;
-enum EM_K1OM  =       181;
-enum EM_INTEL182 =    182;
-enum EM_res183 =      183;
-enum EM_res184 =      184;
-enum EM_AVR32 =       185;
-enum EM_STM8  =       186;
-enum EM_TILE64 =      187;
-enum EM_TILEPRO =     188;
-enum EM_MICROBLAZE =  189;
-enum EM_CUDA  =       190;
-enum EM_TILEGX =      191;
-
 enum EM_486 =           6;
 enum EM_MIPS_RS4_BE =  10;
 enum EM_ALPHA_STD =    41;
-enum EM_ALPHA =    0x9026;
-
-enum SHN_UNDEF =       0;
-enum SHN_LORESERVE =   0xff00;
-enum SHN_LOPROC =      0xff00;
-enum SHN_HIPROC =      0xff1f;
-enum SHN_LOOS =        0xff20;
-enum SHN_HIOS =        0xff3f;
-enum SHN_ABS =         0xfff1;
-enum SHN_COMMON =      0xfff2;
-enum SHN_XINDEX =      0xffff;
-enum SHN_HIRESERVE =   0xffff;
 
-enum PT_NULL =         0;
-enum PT_LOAD =         1;
-enum PT_DYNAMIC =      2;
-enum PT_INTERP =       3;
-enum PT_NOTE =         4;
-enum PT_SHLIB =        5;
-enum PT_PHDR =         6;
-enum PT_TLS =          7;
-enum PT_LOOS =         0x60000000;
-enum PT_HIOS =         0x6fffffff;
-enum PT_LOPROC =       0x70000000;
-enum PT_HIPROC =       0x7fffffff;
-
-enum PT_GNU_EH_FRAME =  PT_LOOS + 0x474e550; /* Frame unwind information */
-enum PT_SUNW_EH_FRAME = PT_GNU_EH_FRAME;     /* Solaris uses the same value */
-enum PT_GNU_STACK =     PT_LOOS + 0x474e551; /* Stack flags */
-enum PT_GNU_RELRO =     PT_LOOS + 0x474e552;  /* Read-only after relocation */
-
-enum PF_X =            0x1;
-enum PF_W =            0x2;
-enum PF_R =            0x4;
-enum PF_MASKOS =       0x0ff00000;
-enum PF_MASKPROC =     0xf0000000;
-
-enum PN_XNUM =         0xffff;
-
-enum SHT_NULL =          0;
-enum SHT_PROGBITS =      1;
-enum SHT_SYMTAB =        2;
-enum SHT_STRTAB =        3;
-enum SHT_RELA =          4;
-enum SHT_HASH =          5;
-enum SHT_DYNAMIC =       6;
-enum SHT_NOTE =          7;
-enum SHT_NOBITS =        8;
-enum SHT_REL =           9;
-enum SHT_SHLIB =         10;
-enum SHT_DYNSYM =        11;
-
-enum SHT_INIT_ARRAY =    14;
-enum SHT_FINI_ARRAY =    15;
-enum SHT_PREINIT_ARRAY = 16;
-enum SHT_GROUP =         17;
-enum SHT_SYMTAB_SHNDX =  18;
-
-enum SHT_LOOS =          0x60000000;
-enum SHT_LOSUNW =        0x6ffffff4;
+enum PT_SUNW_EH_FRAME = PT_GNU_EH_FRAME;
 
 enum SHT_GNU_INCREMENTAL_INPUTS =  0x6fff4700;
-enum SHT_GNU_ATTRIBUTES =       0x6ffffff5;
-enum SHT_GNU_HASH =             0x6ffffff6;
-enum SHT_GNU_LIBLIST =          0x6ffffff7;
 
-//enum SHT_SUNW_dof =      0x6ffffff4;
-//enum SHT_SUNW_cap =      0x6ffffff5;
-//enum SHT_SUNW_SIGNATURE = 0x6ffffff6;
 enum SHT_SUNW_verdef =   0x6ffffffd;
 enum SHT_SUNW_verneed =  0x6ffffffe;
 enum SHT_SUNW_versym =   0x6fffffff;
 
-enum SHT_GNU_verdef =    SHT_SUNW_verdef;
-enum SHT_GNU_verneed =   SHT_SUNW_verneed;
-enum SHT_GNU_versym =    SHT_SUNW_versym;
-
-enum SHT_LOPROC =        0x70000000;
-enum SHT_HIPROC =        0x7fffffff;
-enum SHT_LOUSER =        0x80000000;
-enum SHT_HIUSER =        0x8fffffff;
-
-/*
-enum SHT_GNU_HASH =      0x6ffffff6;
-enum SHT_SUNW_ANNOTATE = 0x6ffffff7;
-enum SHT_SUNW_DEBUGSTR = 0x6ffffff8;
-enum SHT_SUNW_DEBUG =    0x6ffffff9;
-enum SHT_SUNW_move =     0x6ffffffa;
-enum SHT_SUNW_COMDAT =   0x6ffffffb;
-enum SHT_SUNW_syminfo =  0x6ffffffc;
-enum SHT_HISUNW =        0x6fffffff;
-enum SHT_HIOS =          0x6fffffff;
-enum SHT_AMD64_UNWIND =  0x70000001;
-enum SHT_ARM_EXIDX =     0x70000001;
-enum SHT_ARM_PREEMPTMAP = 0x70000002;
-enum SHT_ARM_ATTRIBUTES = 0x70000003;
-enum SHT_ARM_DEBUGOVERLAY = 0x70000004;
-enum SHT_ARM_OVERLAYSECTION = 0x70000005;
-enum SHT_MIPS_REGINFO =  0x70000006;
-enum SHT_MIPS_OPTIONS =  0x7000000d;
-enum SHT_MIPS_DWARF =    0x7000001e;
-*/
-
-enum SHF_WRITE =            (1 << 0);
-enum SHF_ALLOC =            (1 << 1);
-enum SHF_EXECINSTR =        (1 << 2);
-enum SHF_MERGE =            (1 << 4);
-enum SHF_STRINGS =          (1 << 5);
-enum SHF_INFO_LINK =        (1 << 6);
-enum SHF_LINK_ORDER =       (1 << 7);
-enum SHF_OS_NONCONFORMING = (1 << 8);
-enum SHF_GROUP =            (1 << 9);
-enum SHF_TLS =              (1 << 10);
-enum SHF_COMPRESSED =       (1 << 11);
-
-enum SHF_MASKOS =           0x0ff00000;
-enum SHF_MASKPROC =         0xf0000000;
-
 enum NT_PRSTATUS =     1;
 enum NT_FPREGSET =     2;
 enum NT_PRPSINFO =     3;
 enum NT_TASKSTRUCT =   4;
 enum NT_AUXV =         6;
 
-/*
-enum NT_THRMISC =      7;
-enum NT_PROCSTAT_PROC = 8;
-enum NT_PROCSTAT_FILES = 9;
-enum NT_PROCSTAT_VMMAP = 10;
-enum NT_PROCSTAT_GROUPS = 11;
-enum NT_PROCSTAT_UMASK = 12;
-enum NT_PROCSTAT_RLIMIT = 13;
-enum NT_PROCSTAT_OSREL = 14;
-enum NT_PROCSTAT_PSSTRINGS = 15;
-enum NT_PROCSTAT_AUXV = 16;
-*/
-
-enum STN_UNDEF =       0;
-
-enum STB_LOCAL =       0;
-enum STB_GLOBAL =      1;
-enum STB_WEAK =        2;
-enum STB_NUM =         3;
-enum STB_LOOS =        10;
-enum STB_HIOS =        12;
-enum STB_LOPROC =      13;
-enum STB_HIPROC =      15;
-
-enum STT_NOTYPE =      0;
-enum STT_OBJECT =      1;
-enum STT_FUNC =        2;
-enum STT_SECTION =     3;
-enum STT_FILE =        4;
-enum STT_COMMON =      5;
-enum STT_TLS =         6;
-enum STT_NUM =         7;
-enum STT_LOOS =        10;
-enum STT_GNU_IFUNC =   10;
-enum STT_HIOS =        12;
-enum STT_LOPROC =      13;
-enum STT_HIPROC =      15;
-
-enum STV_DEFAULT =     0;
-enum STV_INTERNAL =    1;
-enum STV_HIDDEN =      2;
-enum STV_PROTECTED =   3;
-/*
-enum STV_EXPORTED =    4;
-enum STV_SINGLETON =   5;
-enum STV_ELIMINATE =   6;
-*/
-
-enum DT_NULL =         0;
-enum DT_NEEDED =       1;
-enum DT_PLTRELSZ =     2;
-enum DT_PLTGOT =       3;
-enum DT_HASH =         4;
-enum DT_STRTAB =       5;
-enum DT_SYMTAB =       6;
-enum DT_RELA =         7;
-enum DT_RELASZ =       8;
-enum DT_RELAENT =      9;
-enum DT_STRSZ =        10;
-enum DT_SYMENT =       11;
-enum DT_INIT =         12;
-enum DT_FINI =         13;
-enum DT_SONAME =       14;
-enum DT_RPATH =        15;
-enum DT_SYMBOLIC =     16;
-enum DT_REL =          17;
-enum DT_RELSZ =        18;
-enum DT_RELENT =       19;
-enum DT_PLTREL =       20;
-enum DT_DEBUG =        21;
-enum DT_TEXTREL =      22;
-enum DT_JMPREL =       23;
-enum DT_BIND_NOW =     24;
-enum DT_INIT_ARRAY =   25;
-enum DT_FINI_ARRAY =   26;
-enum DT_INIT_ARRAYSZ = 27;
-enum DT_FINI_ARRAYSZ = 28;
-enum DT_RUNPATH =      29;
-enum DT_FLAGS =        30;
-
-enum DT_ENCODING =     32;
-enum DT_PREINIT_ARRAY = 32;
-enum DT_PREINIT_ARRAYSZ = 33;
-//enum DT_MAXPOSTAGS =   34;
-enum DT_LOOS =         0x6000000d;
-enum DT_HIOS =         0x6ffff000;
-/*
-enum DT_SUNW_AUXILIARY = 0x6000000d;
-enum DT_SUNW_RTLDINF = 0x6000000e;
-enum DT_SUNW_FILTER =  0x6000000f;
-enum DT_SUNW_CAP =     0x60000010;
-*/
-
-enum DT_VALRNGLO =     0x6ffffd00;
-enum DT_GNU_PRELINKED = 0x6ffffdf5;
-enum DT_GNU_CONFLICTSZ =0x6ffffdf6;
-enum DT_GNU_LIBLISTSZ = 0x6ffffdf7;
-enum DT_CHECKSUM =     0x6ffffdf8;
-enum DT_PLTPADSZ =     0x6ffffdf9;
-enum DT_MOVEENT =      0x6ffffdfa;
-enum DT_MOVESZ =       0x6ffffdfb;
-enum DT_FEATURE_1 =    0x6ffffdfc;
-enum DT_POSFLAG_1 =    0x6ffffdfd;
-enum DT_SYMINSZ =      0x6ffffdfe;
-enum DT_SYMINENT =     0x6ffffdff;
-enum DT_VALRNGHI =     0x6ffffdff;
-enum DT_ADDRRNGLO =    0x6ffffe00;
-enum DT_GNU_HASH =     0x6ffffef5;
-enum DT_TLSDESC_PLT =  0x6ffffef6;
-enum DT_TLSDESC_GOT =  0x6ffffef7;
-enum DT_GNU_CONFLICT = 0x6ffffef8;
-enum DT_GNU_LIBLIST =  0x6ffffef9;
-enum DT_CONFIG =       0x6ffffefa;
-enum DT_DEPAUDIT =     0x6ffffefb;
-enum DT_AUDIT =        0x6ffffefc;
-enum DT_PLTPAD =       0x6ffffefd;
-enum DT_MOVETAB =      0x6ffffefe;
-enum DT_SYMINFO =      0x6ffffeff;
-enum DT_ADDRRNGHI =    0x6ffffeff;
-enum DT_RELACOUNT =    0x6ffffff9;
-enum DT_RELCOUNT =     0x6ffffffa;
-enum DT_FLAGS_1 =      0x6ffffffb;
-enum DT_VERDEF =       0x6ffffffc;
-enum DT_VERDEFNUM =    0x6ffffffd;
-enum DT_VERNEED =      0x6ffffffe;
-enum DT_VERNEEDNUM =   0x6fffffff;
-enum DT_VERSYM =       0x6ffffff0;
-enum DT_LOPROC =       0x70000000;
-//enum DT_DEPRECATED_SPARC_REGISTER = 0x7000001;
-enum DT_AUXILIARY =    0x7ffffffd;
 enum DT_USED =         0x7ffffffe;
-enum DT_FILTER =       0x7fffffff;
-enum DT_HIPROC =       0x7fffffff;
-
-enum DTF_1_PARINIT =   0x00000001;
-enum DTF_1_CONFEXP =   0x00000002;
-
-enum DF_P1_LAZYLOAD =  0x00000001;
-enum DF_P1_GROUPPERM=  0x00000002;
 
-enum DF_1_NOW =        0x00000001;
 enum DF_1_BIND_NOW =   0x00000001;
-enum DF_1_GLOBAL =     0x00000002;
-enum DF_1_GROUP =      0x00000004;
-enum DF_1_NODELETE =   0x00000008;
-enum DF_1_LOADFLTR =   0x00000010;
-enum DF_1_INITFIRST =  0x00000020;
-enum DF_1_NOOPEN =     0x00000040;
-enum DF_1_ORIGIN =     0x00000080;
-enum DF_1_DIRECT =     0x00000100;
-enum DF_1_TRANS =      0x00000200;
-enum DF_1_INTERPOSE =  0x00000400;
-enum DF_1_NODEFLIB =   0x00000800;
-enum DF_1_NODUMP =     0x00001000;
-enum DF_1_CONLFAT =    0x00002000;
 
-enum DF_ORIGIN =       0x00000001;
-enum DF_SYMBOLIC =     0x00000002;
-enum DF_TEXTREL =      0x00000004;
-enum DF_BIND_NOW =     0x00000008;
-enum DF_STATIC_TLS =   0x00000010;
-
-enum VER_DEF_NONE =    0;
-enum VER_DEF_CURRENT = 1;
 alias VER_NDX VER_DEF_IDX;
 
-enum VER_FLG_BASE =    0x1;
-enum VER_FLG_WEAK =    0x2;
 enum VER_FLG_INFO =    0x4;
 
-enum VER_NDX_LOCAL =           0;
-enum VER_NDX_GLOBAL =          1;
 enum VER_NDX_GIVEN =           2;
 enum VER_NDX_HIDDEN =      32768;
+
 extern (D) pure @safe
 {
     auto VER_NDX(V)(V v) { return v & ~(1u << 15); }
 }
 
-enum VER_NEED_NONE   = 0;
-enum VER_NEED_CURRENT = 1;
 enum VER_NEED_WEAK =    32768;
 enum VER_NEED_HIDDEN = VER_NDX_HIDDEN;
 alias VER_NDX VER_NEED_IDX;
 
-/*
-enum CA_SUNW_NULL =    0;
-enum CA_SUNW_HW_1 =    1;
-enum CA_SUNW_SF_1 =    2;
-*/
-
 enum VERSYM_HIDDEN =   0x8000;
 enum VERSYM_VERSION =  0x7fff;
 enum ELF_VER_CHR =     '@';
-
-enum SYMINFO_BT_SELF =         0xffff;
-enum SYMINFO_BT_PARENT =       0xfffe;
-//enum SYMINFO_BT_NONE =         0xfffd;
-//enum SYMINFO_BT_EXTERN =       0xfffc;
-enum SYMINFO_BT_LOWRESERVE =   0xff00;
-
-enum SYMINFO_FLG_DIRECT =      0x0001;
-enum SYMINFO_FLG_PASSTHRU =    0x0002;
-enum SYMINFO_FLG_COPY =        0x0004;
-enum SYMINFO_FLG_LAZYLOAD =    0x0008;
-//enum SYMINFO_FLG_DIRECTBIND =  0x0010;
-//enum SYMINFO_FLG_NOEXTDIRECT = 0x0020;
-//enum SYMINFO_FLG_FILTER =      0x0002;
-//enum SYMINFO_FLG_AUXILIARY =   0x0040;
-
-enum SYMINFO_NONE =            0;
-enum SYMINFO_CURRENT =         1;
-enum SYMINFO_NUM =             2;
-
-enum GRP_COMDAT =              0x1;
-
-enum R_386_NONE =               0;
-enum R_386_32 =                 1;
-enum R_386_PC32 =               2;
-enum R_386_GOT32 =              3;
-enum R_386_PLT32 =              4;
-enum R_386_COPY =               5;
-enum R_386_GLOB_DAT =           6;
-enum R_386_JMP_SLOT =           7;
-enum R_386_RELATIVE =           8;
-enum R_386_GOTOFF =             9;
-enum R_386_GOTPC =              10;
-enum R_386_TLS_TPOFF =          14;
-enum R_386_TLS_IE =             15;
-enum R_386_TLS_GOTIE =          16;
-enum R_386_TLS_LE =             17;
-enum R_386_TLS_GD =             18;
-enum R_386_TLS_LDM =            19;
-enum R_386_TLS_GD_32 =          24;
-enum R_386_TLS_GD_PUSH =        25;
-enum R_386_TLS_GD_CALL =        26;
-enum R_386_TLS_GD_POP =         27;
-enum R_386_TLS_LDM_32 =         28;
-enum R_386_TLS_LDM_PUSH =       29;
-enum R_386_TLS_LDM_CALL =       30;
-enum R_386_TLS_LDM_POP =        31;
-enum R_386_TLS_LDO_32 =         32;
-enum R_386_TLS_IE_32 =          33;
-enum R_386_TLS_LE_32 =          34;
-enum R_386_TLS_DTPMOD32 =       35;
-enum R_386_TLS_DTPOFF32 =       36;
-enum R_386_TLS_TPOFF32 =        37;
-enum R_386_IRELATIVE =          42;
-
-enum R_X86_64_NONE =            0;
-enum R_X86_64_64 =              1;
-enum R_X86_64_PC32 =            2;
-enum R_X86_64_GOT32 =           3;
-enum R_X86_64_PLT32 =           4;
-enum R_X86_64_COPY =            5;
-enum R_X86_64_GLOB_DAT =        6;
-enum R_X86_64_JMP_SLOT =        7;
-enum R_X86_64_RELATIVE =        8;
-enum R_X86_64_GOTPCREL =        9;
-enum R_X86_64_32 =              10;
-enum R_X86_64_32S =             11;
-enum R_X86_64_16 =              12;
-enum R_X86_64_PC16 =            13;
-enum R_X86_64_8 =               14;
-enum R_X86_64_PC8 =             15;
-enum R_X86_64_DTPMOD64 =        16;
-enum R_X86_64_DTPOFF64 =        17;
-enum R_X86_64_TPOFF64 =         18;
-enum R_X86_64_TLSGD =           19;
-enum R_X86_64_TLSLD =           20;
-enum R_X86_64_DTPOFF32 =        21;
-enum R_X86_64_GOTTPOFF =        22;
-enum R_X86_64_TPOFF32 =         23;
-enum R_X86_64_IRELATIVE =       37;
index c1309a68c9c4e6805ce19e55feebfda6c9f05510..3a7b753adff87a0e354227113304fd4729d273b6 100644 (file)
@@ -589,9 +589,24 @@ else version (Darwin)
 
     struct cmsghdr
     {
-         socklen_t cmsg_len;
-         int       cmsg_level;
-         int       cmsg_type;
+        socklen_t  cmsg_len;
+        int        cmsg_level;
+        int        cmsg_type;
+    }
+
+
+    extern (D)
+    {
+        socklen_t CMSG_ALIGN(socklen_t len) pure nothrow @nogc { return (len + socklen_t.sizeof - 1) & cast(socklen_t) (~(socklen_t.sizeof - 1)); }
+        socklen_t CMSG_SPACE(socklen_t len) pure nothrow @nogc { return CMSG_ALIGN(len) + CMSG_ALIGN(cmsghdr.sizeof); }
+        socklen_t CMSG_LEN(socklen_t len) pure nothrow @nogc { return CMSG_ALIGN(cmsghdr.sizeof) + len; }
+
+        inout(ubyte)*   CMSG_DATA( return scope inout(cmsghdr)* cmsg ) pure nothrow @nogc { return cast(ubyte*)( cmsg + 1 ); }
+
+        inout(cmsghdr)* CMSG_FIRSTHDR( inout(msghdr)* mhdr ) pure nothrow @nogc
+        {
+            return ( cast(socklen_t)mhdr.msg_controllen >= cmsghdr.sizeof ? cast(inout(cmsghdr)*) mhdr.msg_control : cast(inout(cmsghdr)*) null );
+        }
     }
 
     enum : uint
@@ -599,18 +614,6 @@ else version (Darwin)
         SCM_RIGHTS = 0x01
     }
 
-    /+
-    CMSG_DATA(cmsg)     ((unsigned char *)(cmsg) + \
-                         ALIGN(sizeof(struct cmsghdr)))
-    CMSG_NXTHDR(mhdr, cmsg) \
-                        (((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len) + \
-                         ALIGN(sizeof(struct cmsghdr)) > \
-                         (unsigned char *)(mhdr)->msg_control +(mhdr)->msg_controllen) ? \
-                         (struct cmsghdr *)0 /* NULL */ : \
-                         (struct cmsghdr *)((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len)))
-    CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
-    +/
-
     struct linger
     {
         int l_onoff;
index 7a46d520cc3852261e6c1559a22b38a0de68ed3e..687e7f7d513491eb873f5e3a3113600e6f8c60e5 100644 (file)
@@ -9,7 +9,7 @@ version (Solaris):
 extern (C):
 nothrow:
 
-public import core.sys.solaris.sys.elftypes;
+public import core.sys.elf;
 
 enum ELF32_FSZ_ADDR  = 4;
 enum ELF32_FSZ_HALF  = 2;
@@ -25,333 +25,24 @@ enum ELF64_FSZ_WORD   = 4;
 enum ELF64_FSZ_SXWORD = 8;
 enum ELF64_FSZ_XWORD  = 8;
 
-enum EI_NIDENT = 16;
-
-struct Elf32_Ehdr
-{
-    char[EI_NIDENT] e_ident = 0;
-    Elf32_Half    e_type;
-    Elf32_Half    e_machine;
-    Elf32_Word    e_version;
-    Elf32_Addr    e_entry;
-    Elf32_Off     e_phoff;
-    Elf32_Off     e_shoff;
-    Elf32_Word    e_flags;
-    Elf32_Half    e_ehsize;
-    Elf32_Half    e_phentsize;
-    Elf32_Half    e_phnum;
-    Elf32_Half    e_shentsize;
-    Elf32_Half    e_shnum;
-    Elf32_Half    e_shstrndx;
-}
-
-struct Elf64_Ehdr
-{
-    char[EI_NIDENT] e_ident = 0;
-    Elf64_Half    e_type;
-    Elf64_Half    e_machine;
-    Elf64_Word    e_version;
-    Elf64_Addr    e_entry;
-    Elf64_Off     e_phoff;
-    Elf64_Off     e_shoff;
-    Elf64_Word    e_flags;
-    Elf64_Half    e_ehsize;
-    Elf64_Half    e_phentsize;
-    Elf64_Half    e_phnum;
-    Elf64_Half    e_shentsize;
-    Elf64_Half    e_shnum;
-    Elf64_Half    e_shstrndx;
-}
-
-enum EI_MAG0       = 0;
-enum EI_MAG1       = 1;
-enum EI_MAG2       = 2;
-enum EI_MAG3       = 3;
-enum EI_CLASS      = 4;
-enum EI_DATA       = 5;
-enum EI_VERSION    = 6;
-enum EI_OSABI      = 7;
-enum EI_ABIVERSION = 8;
-enum EI_PAD        = 9;
-
-enum ELFMAG0 = 0x7f;
-enum ELFMAG1 = 'E';
-enum ELFMAG2 = 'L';
-enum ELFMAG3 = 'F';
-enum ELFMAG  = "\177ELF";
-enum SELFMAG = 4;
-
-enum ELFCLASSNONE = 0;
-enum ELFCLASS32   = 1;
-enum ELFCLASS64   = 2;
-enum ELFCLASSNUM  = 3;
-
-enum ELFDATANONE = 0;
-enum ELFDATA2LSB = 1;
-enum ELFDATA2MSB = 2;
-enum ELFDATANUM  = 3;
-
-enum ET_NONE       = 0;
-enum ET_REL        = 1;
-enum ET_EXEC       = 2;
-enum ET_DYN        = 3;
-enum ET_CORE       = 4;
-enum ET_NUM        = 5;
-enum ET_LOOS       = 0xfe00;
 enum ET_LOSUNW     = 0xfeff;
 enum ET_SUNWPSEUDO = 0xfeff;
 enum ET_HISUNW     = 0xfeff;
-enum ET_HIOS       = 0xfeff;
-enum ET_LOPROC     = 0xff00;
-enum ET_HIPROC     = 0xffff;
-
-enum EM_NONE        = 0;
-enum EM_M32         = 1;
-enum EM_SPARC       = 2;
-enum EM_386         = 3;
-enum EM_68K         = 4;
-enum EM_88K         = 5;
-enum EM_486         = 6;
-enum EM_860         = 7;
-enum EM_MIPS        = 8;
-enum EM_S370        = 9;
-enum EM_MIPS_RS3_LE = 10;
-enum EM_RS6000      = 11;
-enum EM_UNKNOWN12   = 12;
-enum EM_UNKNOWN13   = 13;
-enum EM_UNKNOWN14   = 14;
-enum EM_PA_RISC     = 15;
-enum EM_PARISC      = EM_PA_RISC;
-enum EM_nCUBE       = 16;
-enum EM_VPP500      = 17;
-enum EM_SPARC32PLUS = 18;
-enum EM_960         = 19;
-enum EM_PPC         = 20;
-enum EM_PPC64       = 21;
-enum EM_S390        = 22;
-enum EM_UNKNOWN22   = EM_S390;
-enum EM_UNKNOWN23   = 23;
-enum EM_UNKNOWN24   = 24;
-enum EM_UNKNOWN25   = 25;
-enum EM_UNKNOWN26   = 26;
-enum EM_UNKNOWN27   = 27;
-enum EM_UNKNOWN28   = 28;
-enum EM_UNKNOWN29   = 29;
-enum EM_UNKNOWN30   = 30;
-enum EM_UNKNOWN31   = 31;
-enum EM_UNKNOWN32   = 32;
-enum EM_UNKNOWN33   = 33;
-enum EM_UNKNOWN34   = 34;
-enum EM_UNKNOWN35   = 35;
-enum EM_V800        = 36;
-enum EM_FR20        = 37;
-enum EM_RH32        = 38;
-enum EM_RCE         = 39;
-enum EM_ARM         = 40;
-enum EM_ALPHA       = 41;
-enum EM_SH          = 42;
-enum EM_SPARCV9     = 43;
-enum EM_TRICORE     = 44;
-enum EM_ARC         = 45;
-enum EM_H8_300      = 46;
-enum EM_H8_300H     = 47;
-enum EM_H8S         = 48;
-enum EM_H8_500      = 49;
-enum EM_IA_64       = 50;
-enum EM_MIPS_X      = 51;
-enum EM_COLDFIRE    = 52;
-enum EM_68HC12      = 53;
-enum EM_MMA         = 54;
-enum EM_PCP         = 55;
-enum EM_NCPU        = 56;
-enum EM_NDR1        = 57;
-enum EM_STARCORE    = 58;
-enum EM_ME16        = 59;
-enum EM_ST100       = 60;
-enum EM_TINYJ       = 61;
-enum EM_AMD64       = 62;
-enum EM_X86_64      = EM_AMD64;
-enum EM_PDSP        = 63;
-enum EM_UNKNOWN64   = 64;
-enum EM_UNKNOWN65   = 65;
-enum EM_FX66        = 66;
-enum EM_ST9PLUS     = 67;
-enum EM_ST7         = 68;
-enum EM_68HC16      = 69;
-enum EM_68HC11      = 70;
-enum EM_68HC08      = 71;
-enum EM_68HC05      = 72;
-enum EM_SVX         = 73;
-enum EM_ST19        = 74;
-enum EM_VAX         = 75;
-enum EM_CRIS        = 76;
-enum EM_JAVELIN     = 77;
-enum EM_FIREPATH    = 78;
-enum EM_ZSP         = 79;
-enum EM_MMIX        = 80;
-enum EM_HUANY       = 81;
-enum EM_PRISM       = 82;
-enum EM_AVR         = 83;
-enum EM_FR30        = 84;
-enum EM_D10V        = 85;
-enum EM_D30V        = 86;
-enum EM_V850        = 87;
-enum EM_M32R        = 88;
-enum EM_MN10300     = 89;
-enum EM_MN10200     = 90;
-enum EM_PJ          = 91;
-enum EM_OPENRISC    = 92;
-enum EM_ARC_A5      = 93;
-enum EM_XTENSA      = 94;
-enum EM_NUM         = 95;
-
-enum EV_NONE    = 0;
-enum EV_CURRENT = 1;
-enum EV_NUM     = 2;
-
-
-enum ELFOSABI_NONE        = 0;
-enum ELFOSABI_SYSV        = ELFOSABI_NONE;
-enum ELFOSABI_HPUX        = 1;
-enum ELFOSABI_NETBSD      = 2;
-enum ELFOSABI_LINUX       = 3;
-enum ELFOSABI_UNKNOWN4    = 4;
-enum ELFOSABI_UNKNOWN5    = 5;
-enum ELFOSABI_SOLARIS     = 6;
-enum ELFOSABI_AIX         = 7;
-enum ELFOSABI_IRIX        = 8;
-enum ELFOSABI_FREEBSD     = 9;
-enum ELFOSABI_TRU64       = 10;
-enum ELFOSABI_MODESTO     = 11;
-enum ELFOSABI_OPENBSD     = 12;
-enum ELFOSABI_OPENVMS     = 13;
-enum ELFOSABI_NSK         = 14;
-enum ELFOSABI_AROS        = 15;
-enum ELFOSABI_ARM         = 97;
-enum ELFOSABI_STANDALONE  = 255;
-enum ELFOSABI_DRAGONFLYBSD= ELFOSABI_NONE;
 
 enum EAV_SUNW_NONE    = 0;
 enum EAV_SUNW_CURRENT = 1;
 enum EAV_SUNW_NUM     = 2;
 
-struct Elf32_Phdr
-{
-    Elf32_Word    p_type;
-    Elf32_Off     p_offset;
-    Elf32_Addr    p_vaddr;
-    Elf32_Addr    p_paddr;
-    Elf32_Word    p_filesz;
-    Elf32_Word    p_memsz;
-    Elf32_Word    p_flags;
-    Elf32_Word    p_align;
-}
-
-struct Elf64_Phdr
-{
-    Elf64_Word    p_type;
-    Elf64_Word    p_flags;
-    Elf64_Off     p_offset;
-    Elf64_Addr    p_vaddr;
-    Elf64_Addr    p_paddr;
-    Elf64_Xword   p_filesz;
-    Elf64_Xword   p_memsz;
-    Elf64_Xword   p_align;
-}
-
-enum PT_NULL    = 0;
-enum PT_LOAD    = 1;
-enum PT_DYNAMIC = 2;
-enum PT_INTERP  = 3;
-enum PT_NOTE    = 4;
-enum PT_SHLIB   = 5;
-enum PT_PHDR    = 6;
-enum PT_TLS     = 7;
-enum PT_NUM     = 8;
-
-enum PT_LOOS    = 0x60000000;
-
 enum PT_SUNW_UNWIND   = 0x6464e550;
 enum PT_SUNW_EH_FRAME = 0x6474e550;
-enum PT_GNU_EH_FRAME  = PT_SUNW_EH_FRAME;
 
-enum PT_GNU_STACK = 0x6474e551;
-enum PT_GNU_RELRO = 0x6474e552;
-
-enum PT_LOSUNW     = 0x6ffffffa;
-enum PT_SUNWBSS    = 0x6ffffffa;
-enum PT_SUNWSTACK  = 0x6ffffffb;
 enum PT_SUNWDTRACE = 0x6ffffffc;
 enum PT_SUNWCAP    = 0x6ffffffd;
-enum PT_HISUNW     = 0x6fffffff;
-enum PT_HIOS       = 0x6fffffff;
-enum PT_LOPROC     = 0x70000000;
-enum PT_HIPROC     = 0x7fffffff;
-
-enum PF_R = 0x4;
-enum PF_W = 0x2;
-enum PF_X = 0x1;
-
-enum PF_MASKOS   = 0x0ff00000;
-enum PF_MASKPROC = 0xf0000000;
 
 enum PF_SUNW_FAILURE = 0x00100000;
 enum PF_SUNW_KILLED  = 0x00200000;
 enum PF_SUNW_SIGINFO = 0x00400000;
 
-enum PN_XNUM = 0xffff;
-
-struct Elf32_Shdr
-{
-    Elf32_Word    sh_name;
-    Elf32_Word    sh_type;
-    Elf32_Word    sh_flags;
-    Elf32_Addr    sh_addr;
-    Elf32_Off     sh_offset;
-    Elf32_Word    sh_size;
-    Elf32_Word    sh_link;
-    Elf32_Word    sh_info;
-    Elf32_Word    sh_addralign;
-    Elf32_Word    sh_entsize;
-}
-
-struct Elf64_Shdr
-{
-    Elf64_Word    sh_name;
-    Elf64_Word    sh_type;
-    Elf64_Xword   sh_flags;
-    Elf64_Addr    sh_addr;
-    Elf64_Off     sh_offset;
-    Elf64_Xword   sh_size;
-    Elf64_Word    sh_link;
-    Elf64_Word    sh_info;
-    Elf64_Xword   sh_addralign;
-    Elf64_Xword   sh_entsize;
-}
-
-enum SHT_NULL          = 0;
-enum SHT_PROGBITS      = 1;
-enum SHT_SYMTAB        = 2;
-enum SHT_STRTAB        = 3;
-enum SHT_RELA          = 4;
-enum SHT_HASH          = 5;
-enum SHT_DYNAMIC       = 6;
-enum SHT_NOTE          = 7;
-enum SHT_NOBITS        = 8;
-enum SHT_REL           = 9;
-enum SHT_SHLIB         = 10;
-enum SHT_DYNSYM        = 11;
-enum SHT_UNKNOWN12     = 12;
-enum SHT_UNKNOWN13     = 13;
-enum SHT_INIT_ARRAY    = 14;
-enum SHT_FINI_ARRAY    = 15;
-enum SHT_PREINIT_ARRAY = 16;
-enum SHT_GROUP         = 17;
-enum SHT_SYMTAB_SHNDX  = 18;
-enum SHT_NUM           = 19;
-
-enum SHT_LOOS           = 0x60000000;
-enum SHT_LOSUNW         = 0x6fffffef;
 enum SHT_SUNW_capchain  = 0x6fffffef;
 enum SHT_SUNW_capinfo   = 0x6ffffff0;
 enum SHT_SUNW_symsort   = 0x6ffffff1;
@@ -363,106 +54,9 @@ enum SHT_SUNW_SIGNATURE = 0x6ffffff6;
 enum SHT_SUNW_ANNOTATE  = 0x6ffffff7;
 enum SHT_SUNW_DEBUGSTR  = 0x6ffffff8;
 enum SHT_SUNW_DEBUG     = 0x6ffffff9;
-enum SHT_SUNW_move      = 0x6ffffffa;
-enum SHT_SUNW_COMDAT    = 0x6ffffffb;
-enum SHT_SUNW_syminfo   = 0x6ffffffc;
 enum SHT_SUNW_verdef    = 0x6ffffffd;
-enum SHT_GNU_verdef     = SHT_SUNW_verdef;
 enum SHT_SUNW_verneed   = 0x6ffffffe;
-enum SHT_GNU_verneed    = SHT_SUNW_verneed;
 enum SHT_SUNW_versym    = 0x6fffffff;
-enum SHT_GNU_versym     = SHT_SUNW_versym;
-enum SHT_HISUNW         = 0x6fffffff;
-enum SHT_HIOS           = 0x6fffffff;
-enum SHT_GNU_ATTRIBUTES = 0x6ffffff5;
-enum SHT_GNU_HASH       = 0x6ffffff6;
-enum SHT_GNU_LIBLIST    = 0x6ffffff7;
-enum SHT_CHECKSUM       = 0x6ffffff8;
-enum SHT_LOPROC         = 0x70000000;
-enum SHT_HIPROC         = 0x7fffffff;
-enum SHT_LOUSER         = 0x80000000;
-enum SHT_HIUSER         = 0xffffffff;
-
-enum SHF_WRITE            = 0x01;
-enum SHF_ALLOC            = 0x02;
-enum SHF_EXECINSTR        = 0x04;
-enum SHF_MERGE            = 0x10;
-enum SHF_STRINGS          = 0x20;
-enum SHF_INFO_LINK        = 0x40;
-enum SHF_LINK_ORDER       = 0x80;
-enum SHF_OS_NONCONFORMING = 0x100;
-enum SHF_GROUP            = 0x200;
-enum SHF_TLS              = 0x400;
-enum SHF_COMPRESSED       = 0x800;
-enum SHF_MASKOS = 0x0ff00000;
-
-enum SHF_MASKPROC = 0xf0000000;
-
-enum SHN_UNDEF       = 0;
-enum SHN_LORESERVE   = 0xff00;
-enum SHN_LOPROC      = 0xff00;
-enum SHN_HIPROC      = 0xff1f;
-enum SHN_LOOS        = 0xff20;
-enum SHN_LOSUNW      = 0xff3f;
-enum SHN_SUNW_IGNORE = 0xff3f;
-enum SHN_HISUNW      = 0xff3f;
-enum SHN_HIOS        = 0xff3f;
-enum SHN_ABS         = 0xfff1;
-enum SHN_COMMON      = 0xfff2;
-enum SHN_XINDEX      = 0xffff;
-enum SHN_HIRESERVE   = 0xffff;
-
-struct Elf32_Sym
-{
-    Elf32_Word    st_name;
-    Elf32_Addr    st_value;
-    Elf32_Word    st_size;
-    ubyte         st_info;
-    ubyte         st_other;
-    Elf32_Half    st_shndx;
-}
-
-struct Elf64_Sym
-{
-    Elf64_Word    st_name;
-    ubyte         st_info;
-    ubyte         st_other;
-    Elf64_Half    st_shndx;
-    Elf64_Addr    st_value;
-    Elf64_Xword   st_size;
-}
-
-enum STN_UNDEF  = 0;
-
-extern (D)
-{
-    auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
-    auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; }
-    auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); }
-    alias ELF32_ST_BIND ELF64_ST_BIND;
-    alias ELF32_ST_TYPE ELF64_ST_TYPE;
-    alias ELF32_ST_INFO ELF64_ST_INFO;
-}
-
-enum STB_LOCAL  = 0;
-enum STB_GLOBAL = 1;
-enum STB_WEAK   = 2;
-enum STB_NUM    = 3;
-enum STB_LOPROC = 13;
-enum STB_HIPROC = 15;
-
-enum STT_NOTYPE  = 0;
-enum STT_OBJECT  = 1;
-enum STT_FUNC    = 2;
-enum STT_SECTION = 3;
-enum STT_FILE    = 4;
-enum STT_COMMON  = 5;
-enum STT_TLS     = 6;
-enum STT_NUM     = 7;
-enum STT_LOOS    = 10;
-enum STT_HIOS    = 12;
-enum STT_LOPROC  = 13;
-enum STT_HIPROC  = 15;
 
 extern (D)
 {
@@ -470,58 +64,18 @@ extern (D)
     alias ELF32_ST_VISIBILITY ELF64_ST_VISIBILITY;
 }
 
-enum STV_DEFAULT   = 0;
-enum STV_INTERNAL  = 1;
-enum STV_HIDDEN    = 2;
-enum STV_PROTECTED = 3;
 enum STV_EXPORTED  = 4;
 enum STV_SINGLETON = 5;
 enum STV_ELIMINATE = 6;
 enum STV_NUM       = 7;
 
-struct Elf32_Rel
-{
-    Elf32_Addr    r_offset;
-    Elf32_Word    r_info;
-}
-
-struct Elf32_Rela
-{
-    Elf32_Addr    r_offset;
-    Elf32_Word    r_info;
-    Elf32_Sword   r_addend;
-}
-
-struct Elf64_Rel
-{
-    Elf64_Addr    r_offset;
-    Elf64_Xword   r_info;
-}
-
-struct Elf64_Rela
-{
-    Elf64_Addr    r_offset;
-    Elf64_Xword   r_info;
-    Elf64_Sxword  r_addend;
-}
-
 extern (D)
 {
-    auto ELF32_R_SYM(V)(V val) { return val >> 8; }
-    auto ELF32_R_TYPE(V)(V val) { return val & 0xff; }
-    auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); }
-
-    auto ELF64_R_SYM(I)(I i) { return i >> 32; }
-    auto ELF64_R_TYPE(I)(I i) { return i & 0xffffffff; }
-    auto ELF64_R_INFO(S, T)(S sym, T type) { return (sym << 32) + (type); }
-
     auto ELF64_R_TYPE_DATA(I)(I i) { return (i << 32) >> 40; }
     auto ELF64_R_TYPE_ID(I)(I i) { return (i << 56) >> 56; }
     auto ELF64_R_TYPE_INFO(S, T)(S sym, T type) { return (sym <<8) + (type); }
 }
 
-enum GRP_COMDAT = 0x01;
-
 struct Elf32_Nhdr
 {
     Elf32_Word n_namesz;
@@ -536,35 +90,6 @@ struct Elf64_Nhdr
     Elf64_Word n_type;
 }
 
-struct Elf32_Move
-{
-    Elf32_Lword m_value;
-    Elf32_Word  m_info;
-    Elf32_Word  m_poffset;
-    Elf32_Half  m_repeat;
-    Elf32_Half  m_stride;
-}
-
-extern (D)
-{
-    auto ELF32_M_SYM(I)(I info) { return info >> 8; }
-    auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; }
-    auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; }
-}
-
-struct Elf64_Move
-{
-    Elf64_Lword m_value;
-    Elf64_Xword m_info;
-    Elf64_Xword m_poffset;
-    Elf64_Half  m_repeat;
-    Elf64_Half  m_stride;
-}
-
-alias ELF32_M_SYM ELF64_M_SYM;
-alias ELF32_M_SIZE ELF64_M_SIZE;
-alias ELF32_M_INFO ELF64_M_INFO;
-
 struct Elf32_Cap
 {
     Elf32_Word  c_tag;
@@ -578,7 +103,6 @@ struct Elf32_Cap
 alias Elf32_Word Elf32_Capinfo;
 alias Elf32_Word Elf32_Capchain;
 
-
 alias ELF32_M_SYM ELF32_C_SYM;
 alias ELF32_M_SIZE ELF32_C_GROUP;
 alias ELF32_M_INFO ELF32_C_INFO;
@@ -596,13 +120,6 @@ struct Elf64_Cap
 alias Elf64_Xword Elf64_Capinfo;
 alias Elf64_Word  Elf64_Capchain;
 
-/*
- *  Macros to compose and decompose values for capabilities info.
- *
- *  sym = ELF64_C_SYM(info)
- *  grp = ELF64_C_GROUP(info)
- *  info = ELF64_C_INFO(sym, grp)
- */
 extern (D)
 {
     auto ELF64_C_SYM(I)(I info) { return info >> 32; }
@@ -656,6 +173,3 @@ enum NT_ZONENAME   = 21;
 enum NT_FDINFO     = 22;
 enum NT_SPYMASTER  = 23;
 enum NT_NUM        = 23;
-
-enum SHF_ORDERED = 0x40000000;
-enum SHF_EXCLUDE = 0x80000000;
index 3695ea60021192a437b0db7fc653b2c15a7329fa..bb9e7ea024084f34845b6bb0d3f797f0a4fc67d4 100644 (file)
@@ -9,6 +9,7 @@
 module core.sys.windows.objbase;
 version (Windows):
 @system:
+nothrow:
 pragma(lib, "ole32");
 
 import core.sys.windows.cguid, core.sys.windows.objidl, core.sys.windows.unknwn, core.sys.windows.wtypes;
index 49d5abf01b64b4414ee90c9734411aa06add2ae9..6db1db883c63876dc4e80fb4c528293c83df5e6d 100644 (file)
@@ -9,6 +9,7 @@
 module core.sys.windows.unknwn;
 version (Windows):
 @system:
+nothrow:
 
 import core.sys.windows.objfwd, core.sys.windows.windef, core.sys.windows.wtypes;
 import core.sys.windows.basetyps;
index ca368098b4b642d74da1e0ae3c0ddb9e6977f3e6..1bbce3f858dac629e4135e704cd700c2071a1807 100644 (file)
@@ -1333,6 +1333,9 @@ private extern (D) ThreadBase attachThread(ThreadBase _thisThread) @nogc nothrow
  *       must be called after thread_attachThis:
  *
  *       extern (C) void rt_moduleTlsCtor();
+ *
+ * See_Also:
+ *     $(REF thread_detachThis, core,thread,threadbase)
  */
 extern(C) Thread thread_attachThis()
 {
@@ -2177,7 +2180,7 @@ extern (C) void thread_init() @nogc
 }
 
 private alias MainThreadStore = void[__traits(classInstanceSize, Thread)];
-package __gshared align(Thread.alignof) MainThreadStore _mainThreadStore;
+package __gshared align(__traits(classInstanceAlignment, Thread)) MainThreadStore _mainThreadStore;
 
 /**
  * Terminates the thread module. No other thread routine may be called
index 9cee4d8d77d270520011a851f4c5210ef54879c6..9042a365242efbfd2b2c873d4f734ad11ceea825 100644 (file)
@@ -80,9 +80,7 @@ private
 {
     // Handling unaligned mutexes are not supported on all platforms, so we must
     // ensure that the address of all shared data are appropriately aligned.
-    import core.internal.traits : classInstanceAlignment;
-
-    enum mutexAlign = classInstanceAlignment!Mutex;
+    enum mutexAlign = __traits(classInstanceAlignment, Mutex);
     enum mutexClassInstanceSize = __traits(classInstanceSize, Mutex);
 
     alias swapContext = externDFunc!("core.thread.osthread.swapContext", void* function(void*) nothrow @nogc);
@@ -820,10 +818,13 @@ package ThreadT thread_attachThis_tpl(ThreadT)()
  *
  * NOTE: This routine does not run thread-local static destructors when called.
  *       If full functionality as a D thread is desired, the following function
- *       must be called after thread_detachThis, particularly if the thread is
+ *       must be called before thread_detachThis, particularly if the thread is
  *       being detached at some indeterminate time before program termination:
  *
  *       $(D extern(C) void rt_moduleTlsDtor();)
+ *
+ * See_Also:
+ *     $(REF thread_attachThis, core,thread,osthread)
  */
 extern (C) void thread_detachThis() nothrow @nogc
 {
index e58afa2f985b785ee99fbe862e8f60d6a6f1af15..3a88552f302d606a644800858d211cbf0319250b 100644 (file)
@@ -4882,7 +4882,8 @@ they are only intended to be instantiated by the compiler, not the user.
 
 public import core.internal.entrypoint : _d_cmain;
 
-public import core.internal.array.appending : _d_arrayappendTImpl;
+public import core.internal.array.appending : _d_arrayappendT;
+public import core.internal.array.appending : _d_arrayappendTTrace;
 public import core.internal.array.appending : _d_arrayappendcTXImpl;
 public import core.internal.array.comparison : __cmp;
 public import core.internal.array.equality : __equals;
index b0e25b570541dd4c022706c88fe273fb1765c37e..96d9a804d7c67dba030eac31a84a3655aca23f50 100644 (file)
@@ -2126,7 +2126,7 @@ extern (C) void[] _d_arrayappendcd(ref byte[] x, dchar c) @weak
 
     // Hack because _d_arrayappendT takes `x` as a reference
     auto xx = cast(shared(char)[])x;
-    object._d_arrayappendTImpl!(shared(char)[])._d_arrayappendT(xx, cast(shared(char)[])appendthis);
+    object._d_arrayappendT(xx, cast(shared(char)[])appendthis);
     x = cast(byte[])xx;
     return x;
 }
@@ -2187,7 +2187,7 @@ extern (C) void[] _d_arrayappendwd(ref byte[] x, dchar c) @weak
     //
 
     auto xx = (cast(shared(wchar)*)x.ptr)[0 .. x.length];
-    object._d_arrayappendTImpl!(shared(wchar)[])._d_arrayappendT(xx, cast(shared(wchar)[])appendthis);
+    object._d_arrayappendT(xx, cast(shared(wchar)[])appendthis);
     x = (cast(byte*)xx.ptr)[0 .. xx.length];
     return x;
 }
index 3218ace50a0d1e9d57aa77284b8418727d1912bd..3de142fe009125770bc6a307380d997deef474ec 100644 (file)
@@ -1,4 +1,4 @@
-ac296f80cda437483b743f953dc69cb1271c82df
+3a1cd9a01479155958c7799e573e55a93dd189a0
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/phobos repository.
index 4f7f3c3915323849c93617bdf198f123e021b49e..94a2e7a001276651e6205c9265509a568ab9cdae 100644 (file)
@@ -1641,7 +1641,7 @@ package string errnoString(int errno) nothrow @trusted
 class ErrnoException : Exception
 {
     /// Operating system error code.
-    final @property uint errno() nothrow pure @nogc @safe { return _errno; }
+    final @property uint errno() nothrow pure scope @nogc @safe { return _errno; }
     private uint _errno;
     /// Constructor which takes an error message. The current global $(REF errno, core,stdc,errno) value is used as error code.
     this(string msg, string file = null, size_t line = 0) @safe
index 6a28de52ed0a461780d799b622cd1642e7351b72..efc4ef7f74a7620e91cd36adf4cc342e22cabfc5 100644 (file)
@@ -1628,7 +1628,8 @@ private @property Logger defaultSharedLoggerImpl() @trusted
     import core.lifetime : emplace;
     import std.stdio : stderr;
 
-    __gshared align(FileLogger.alignof) void[__traits(classInstanceSize, FileLogger)] _buffer;
+    __gshared align(__traits(classInstanceAlignment, FileLogger))
+        void[__traits(classInstanceSize, FileLogger)] _buffer;
 
     import std.concurrency : initOnce;
     initOnce!stdSharedDefaultLogger({
@@ -1762,9 +1763,8 @@ private @property Logger stdThreadLocalLogImpl() @trusted
 {
     import core.lifetime : emplace;
 
-    static void*[(__traits(classInstanceSize, StdForwardLogger) - 1) / (void*).sizeof + 1] _buffer;
-
-    auto buffer = cast(ubyte[]) _buffer;
+    static align(__traits(classInstanceAlignment, StdForwardLogger))
+        void[__traits(classInstanceSize, StdForwardLogger)] buffer;
 
     if (stdLoggerDefaultThreadLogger is null)
     {
index a9ec930d90c1f874a8cf21342bf88f749254eafb..daf2cecbebe25cbdb45038c998954364dac24c1a 100644 (file)
@@ -968,10 +968,10 @@ if (isUnsigned!F && isUnsigned!G && isUnsigned!H)
 pragma(inline, true)
 real exp(real x) @trusted pure nothrow @nogc // TODO: @safe
 {
-    import std.math.constants : LOG2E;
-
     version (InlineAsm_X87)
     {
+        import std.math.constants : LOG2E;
+
         //  e^^x = 2^^(LOG2E*x)
         // (This is valid because the overflow & underflow limits for exp
         // and exp2 are so similar).
index b768969d4cf5d30c2b3e41aba02ca734ab04cc26..7bff07e86d489019e309d999422b9414ae2d3fb1 100644 (file)
@@ -214,12 +214,12 @@ private:
         }
         else version (SPARC)
         {
-           /*
+            /*
                int retval;
                asm pure nothrow @nogc { st %fsr, retval; }
                return retval;
             */
-           assert(0, "Not yet supported");
+            assert(0, "Not yet supported");
         }
         else version (ARM)
         {
index c434481dda302e81fdc2eecf1ad2dae7d48877d9..92af9a9a16a74865ecf45a91fe7a04568d4efe99 100644 (file)
@@ -173,21 +173,40 @@ class OutBuffer
     }
 
     /****************************************
-     * Append nbytes of 0 to the internal buffer.
+     * Append nbytes of val to the internal buffer.
+     * Params:
+     *   nbytes = Number of bytes to fill.
+     *   val = Value to fill, defaults to 0.
      */
 
-    void fill0(size_t nbytes)
+    void fill(size_t nbytes, ubyte val = 0)
     {
         reserve(nbytes);
-        data[offset .. offset + nbytes] = 0;
+        data[offset .. offset + nbytes] = val;
         offset += nbytes;
     }
 
+    /****************************************
+     * Append nbytes of 0 to the internal buffer.
+     * Param:
+     *   nbytes - number of bytes to fill.
+     */
+    void fill0(size_t nbytes)
+    {
+        fill(nbytes);
+    }
+
     /**********************************
-     * 0-fill to align on power of 2 boundary.
+     * Append bytes until the buffer aligns on a power of 2 boundary.
+     *
+     * By default fills with 0 bytes.
+     *
+     * Params:
+     *   alignsize = Alignment value. Must be power of 2.
+     *   val = Value to fill, defaults to 0.
      */
 
-    void alignSize(size_t alignsize)
+    void alignSize(size_t alignsize, ubyte val = 0)
     in
     {
         assert(alignsize && (alignsize & (alignsize - 1)) == 0);
@@ -200,7 +219,35 @@ class OutBuffer
     {
         auto nbytes = offset & (alignsize - 1);
         if (nbytes)
-            fill0(alignsize - nbytes);
+            fill(alignsize - nbytes, val);
+    }
+    ///
+    @safe unittest
+    {
+        OutBuffer buf = new OutBuffer();
+        buf.write(cast(ubyte) 1);
+        buf.align2();
+        assert(buf.toBytes() == "\x01\x00");
+        buf.write(cast(ubyte) 2);
+        buf.align4();
+        assert(buf.toBytes() == "\x01\x00\x02\x00");
+        buf.write(cast(ubyte) 3);
+        buf.alignSize(8);
+        assert(buf.toBytes() == "\x01\x00\x02\x00\x03\x00\x00\x00");
+    }
+    /// ditto
+    @safe unittest
+    {
+        OutBuffer buf = new OutBuffer();
+        buf.write(cast(ubyte) 1);
+        buf.align2(0x55);
+        assert(buf.toBytes() == "\x01\x55");
+        buf.write(cast(ubyte) 2);
+        buf.align4(0x55);
+        assert(buf.toBytes() == "\x01\x55\x02\x55");
+        buf.write(cast(ubyte) 3);
+        buf.alignSize(8, 0x55);
+        assert(buf.toBytes() == "\x01\x55\x02\x55\x03\x55\x55\x55");
     }
 
     /// Clear the data in the buffer
@@ -211,23 +258,27 @@ class OutBuffer
 
     /****************************************
      * Optimize common special case alignSize(2)
+     * Params:
+     *   val = Value to fill, defaults to 0.
      */
 
-    void align2()
+    void align2(ubyte val = 0)
     {
         if (offset & 1)
-            write(cast(byte) 0);
+            write(cast(byte) val);
     }
 
     /****************************************
      * Optimize common special case alignSize(4)
+     * Params:
+     *   val = Value to fill, defaults to 0.
      */
 
-    void align4()
+    void align4(ubyte val = 0)
     {
         if (offset & 3)
         {   auto nbytes = (4 - offset) & 3;
-            fill0(nbytes);
+            fill(nbytes, val);
         }
     }
 
index 915159f180fad460acc27c9698ea0d74f0216e3a..6ec798581947070092b9394e316b849652bdd3da 100644 (file)
@@ -122,6 +122,12 @@ version (StdUnittest)
                 writefln("Ignoring std.socket(%d) test failure (likely caused by flaky environment): %s", line, e.msg);
         }
     }
+
+    // Without debug=std_socket, still compile the slow tests, just don't run them.
+    debug (std_socket)
+        private enum runSlowTests = true;
+    else
+        private enum runSlowTests = false;
 }
 
 /// Base exception thrown by `std.socket`.
@@ -1698,7 +1704,7 @@ public:
         }
     });
 
-    debug (std_socket)
+    if (runSlowTests)
     softUnittest({
         // test failing reverse lookup
         const InternetAddress ia = new InternetAddress("255.255.255.255", 80);
@@ -2633,7 +2639,7 @@ private:
 
     @safe unittest
     {
-        debug (std_socket)
+        if (runSlowTests)
         softUnittest({
             import std.datetime.stopwatch;
             import std.typecons;
@@ -3000,7 +3006,7 @@ public:
      * Returns: The number of bytes actually sent, or `Socket.ERROR` on
      * failure.
      */
-    ptrdiff_t send(const(void)[] buf, SocketFlags flags) @trusted
+    ptrdiff_t send(scope const(void)[] buf, SocketFlags flags) @trusted
     {
         static if (is(typeof(MSG_NOSIGNAL)))
         {
@@ -3014,7 +3020,7 @@ public:
     }
 
     /// ditto
-    ptrdiff_t send(const(void)[] buf)
+    ptrdiff_t send(scope const(void)[] buf)
     {
         return send(buf, SocketFlags.NONE);
     }
@@ -3026,7 +3032,7 @@ public:
      * Returns: The number of bytes actually sent, or `Socket.ERROR` on
      * failure.
      */
-    ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags, Address to) @trusted
+    ptrdiff_t sendTo(scope const(void)[] buf, SocketFlags flags, Address to) @trusted
     {
         static if (is(typeof(MSG_NOSIGNAL)))
         {
@@ -3042,7 +3048,7 @@ public:
     }
 
     /// ditto
-    ptrdiff_t sendTo(const(void)[] buf, Address to)
+    ptrdiff_t sendTo(scope const(void)[] buf, Address to)
     {
         return sendTo(buf, SocketFlags.NONE, to);
     }
@@ -3050,7 +3056,7 @@ public:
 
     //assumes you connect()ed
     /// ditto
-    ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags) @trusted
+    ptrdiff_t sendTo(scope const(void)[] buf, SocketFlags flags) @trusted
     {
         static if (is(typeof(MSG_NOSIGNAL)))
         {
@@ -3065,7 +3071,7 @@ public:
 
     //assumes you connect()ed
     /// ditto
-    ptrdiff_t sendTo(const(void)[] buf)
+    ptrdiff_t sendTo(scope const(void)[] buf)
     {
         return sendTo(buf, SocketFlags.NONE);
     }
@@ -3077,7 +3083,7 @@ public:
      * Returns: The number of bytes actually received, `0` if the remote side
      * has closed the connection, or `Socket.ERROR` on failure.
      */
-    ptrdiff_t receive(void[] buf, SocketFlags flags) @trusted
+    ptrdiff_t receive(scope void[] buf, SocketFlags flags) @trusted
     {
         version (Windows)         // Does not use size_t
         {
@@ -3094,7 +3100,7 @@ public:
     }
 
     /// ditto
-    ptrdiff_t receive(void[] buf)
+    ptrdiff_t receive(scope void[] buf)
     {
         return receive(buf, SocketFlags.NONE);
     }
@@ -3106,7 +3112,7 @@ public:
      * Returns: The number of bytes actually received, `0` if the remote side
      * has closed the connection, or `Socket.ERROR` on failure.
      */
-    ptrdiff_t receiveFrom(void[] buf, SocketFlags flags, ref Address from) @trusted
+    ptrdiff_t receiveFrom(scope void[] buf, SocketFlags flags, ref Address from) @trusted
     {
         if (!buf.length)         //return 0 and don't think the connection closed
             return 0;
@@ -3129,7 +3135,7 @@ public:
 
 
     /// ditto
-    ptrdiff_t receiveFrom(void[] buf, ref Address from)
+    ptrdiff_t receiveFrom(scope void[] buf, ref Address from)
     {
         return receiveFrom(buf, SocketFlags.NONE, from);
     }
@@ -3137,7 +3143,7 @@ public:
 
     //assumes you connect()ed
     /// ditto
-    ptrdiff_t receiveFrom(void[] buf, SocketFlags flags) @trusted
+    ptrdiff_t receiveFrom(scope void[] buf, SocketFlags flags) @trusted
     {
         if (!buf.length)         //return 0 and don't think the connection closed
             return 0;
@@ -3158,7 +3164,7 @@ public:
 
     //assumes you connect()ed
     /// ditto
-    ptrdiff_t receiveFrom(void[] buf)
+    ptrdiff_t receiveFrom(scope void[] buf)
     {
         return receiveFrom(buf, SocketFlags.NONE);
     }
@@ -3169,7 +3175,7 @@ public:
      * Returns: The number of bytes written to `result`.
      * The length, in bytes, of the actual result - very different from getsockopt()
      */
-    int getOption(SocketOptionLevel level, SocketOption option, void[] result) @trusted
+    int getOption(SocketOptionLevel level, SocketOption option, scope void[] result) @trusted
     {
         socklen_t len = cast(socklen_t) result.length;
         if (_SOCKET_ERROR == .getsockopt(sock, cast(int) level, cast(int) option, result.ptr, &len))
@@ -3217,7 +3223,7 @@ public:
     }
 
     /// Set a socket option.
-    void setOption(SocketOptionLevel level, SocketOption option, void[] value) @trusted
+    void setOption(SocketOptionLevel level, SocketOption option, scope void[] value) @trusted
     {
         if (_SOCKET_ERROR == .setsockopt(sock, cast(int) level,
                                         cast(int) option, value.ptr, cast(uint) value.length))
@@ -3647,55 +3653,55 @@ class UdpSocket: Socket
             {
                 checkAttributes!q{@trusted}; assert(0);
             }
-            @trusted ptrdiff_t send(const(void)[] buf, SocketFlags flags)
+            @trusted ptrdiff_t send(scope const(void)[] buf, SocketFlags flags)
             {
                 checkAttributes!q{@trusted}; assert(0);
             }
-            @safe ptrdiff_t send(const(void)[] buf)
+            @safe ptrdiff_t send(scope const(void)[] buf)
             {
                 checkAttributes!q{@safe}; assert(0);
             }
-            @trusted ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags, Address to)
+            @trusted ptrdiff_t sendTo(scope const(void)[] buf, SocketFlags flags, Address to)
             {
                 checkAttributes!q{@trusted}; assert(0);
             }
-            @safe ptrdiff_t sendTo(const(void)[] buf, Address to)
+            @safe ptrdiff_t sendTo(scope const(void)[] buf, Address to)
             {
                 checkAttributes!q{@safe}; assert(0);
             }
-            @trusted ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags)
+            @trusted ptrdiff_t sendTo(scope const(void)[] buf, SocketFlags flags)
             {
                 checkAttributes!q{@trusted}; assert(0);
             }
-            @safe ptrdiff_t sendTo(const(void)[] buf)
+            @safe ptrdiff_t sendTo(scope const(void)[] buf)
             {
                 checkAttributes!q{@safe}; assert(0);
             }
-            @trusted ptrdiff_t receive(void[] buf, SocketFlags flags)
+            @trusted ptrdiff_t receive(scope void[] buf, SocketFlags flags)
             {
                 checkAttributes!q{@trusted}; assert(0);
             }
-            @safe ptrdiff_t receive(void[] buf)
+            @safe ptrdiff_t receive(scope void[] buf)
             {
                 checkAttributes!q{@safe}; assert(0);
             }
-            @trusted ptrdiff_t receiveFrom(void[] buf, SocketFlags flags, ref Address from)
+            @trusted ptrdiff_t receiveFrom(scope void[] buf, SocketFlags flags, ref Address from)
             {
                 checkAttributes!q{@trusted}; assert(0);
             }
-            @safe ptrdiff_t receiveFrom(void[] buf, ref Address from)
+            @safe ptrdiff_t receiveFrom(scope void[] buf, ref Address from)
             {
                 checkAttributes!q{@safe}; assert(0);
             }
-            @trusted ptrdiff_t receiveFrom(void[] buf, SocketFlags flags)
+            @trusted ptrdiff_t receiveFrom(scope void[] buf, SocketFlags flags)
             {
                 checkAttributes!q{@trusted}; assert(0);
             }
-            @safe ptrdiff_t receiveFrom(void[] buf)
+            @safe ptrdiff_t receiveFrom(scope void[] buf)
             {
                 checkAttributes!q{@safe}; assert(0);
             }
-            @trusted int getOption(SocketOptionLevel level, SocketOption option, void[] result)
+            @trusted int getOption(SocketOptionLevel level, SocketOption option, scope void[] result)
             {
                 checkAttributes!q{@trusted}; assert(0);
             }
@@ -3711,7 +3717,7 @@ class UdpSocket: Socket
             {
                 checkAttributes!q{@trusted};
             }
-            @trusted void setOption(SocketOptionLevel level, SocketOption option, void[] value)
+            @trusted void setOption(SocketOptionLevel level, SocketOption option, scope void[] value)
             {
                 checkAttributes!q{@trusted};
             }
@@ -3793,11 +3799,11 @@ Socket[2] socketPair() @trusted
 ///
 @safe unittest
 {
-    immutable ubyte[] data = [1, 2, 3, 4];
+    immutable ubyte[4] data = [1, 2, 3, 4];
     auto pair = socketPair();
     scope(exit) foreach (s; pair) s.close();
 
-    pair[0].send(data);
+    pair[0].send(data[]);
 
     auto buf = new ubyte[data.length];
     pair[1].receive(buf);
index dac531ff1aec37129462b02952ff1d9f71a3736a..869c36fdfe81425aa72abe5f01241189e9e93f4a 100644 (file)
@@ -1830,7 +1830,7 @@ class MatchException : Exception
 template canMatch(alias handler, Ts...)
 if (Ts.length > 0)
 {
-    enum canMatch = is(typeof((Ts args) => handler(args)));
+    enum canMatch = is(typeof((ref Ts args) => handler(args)));
 }
 
 ///
@@ -2575,6 +2575,27 @@ version (D_Exceptions)
     }
 }
 
+// return ref
+// issue: https://issues.dlang.org/show_bug.cgi?id=23101
+@safe unittest
+{
+    static assert(!__traits(compiles, () {
+        SumType!(int, string) st;
+        return st.match!(
+            function int* (string x) => assert(0),
+            function int* (return ref int i) => &i,
+        );
+    }));
+
+    SumType!(int, string) st;
+    static assert(__traits(compiles, () {
+        return st.match!(
+            function int* (string x) => null,
+            function int* (return ref int i) => &i,
+        );
+    }));
+}
+
 private void destroyIfOwner(T)(ref T value)
 {
     static if (hasElaborateDestructor!T)
index 18400e3e859823b643be0d85c17a71b39c2f86b4..cc08ea638be82a133c529c1fff956cfe41a77804 100644 (file)
@@ -788,7 +788,8 @@ private template fqnType(T,
                 ~ (attrs & FA.trusted ? " @trusted" : "")
                 ~ (attrs & FA.safe ? " @safe" : "")
                 ~ (attrs & FA.nogc ? " @nogc" : "")
-                ~ (attrs & FA.return_ ? " return" : "");
+                ~ (attrs & FA.return_ ? " return" : "")
+                ~ (attrs & FA.live ? " @live" : "");
     }
 
     string addQualifiers(string typeString,
@@ -4838,7 +4839,7 @@ Returns class instance alignment.
 template classInstanceAlignment(T)
 if (is(T == class))
 {
-    alias classInstanceAlignment = maxAlignment!(void*, typeof(T.tupleof));
+    enum classInstanceAlignment = __traits(classInstanceAlignment, T);
 }
 
 ///
index 1ee7faaee7bc9263800d5399e1bba29e46e0d978..8a3e22f74a95b20370f85e650ff6d234eb66c2f4 100644 (file)
@@ -8267,7 +8267,7 @@ if (is(T == class))
 {
     // _d_newclass now use default GC alignment (looks like (void*).sizeof * 2 for
     // small objects). We will just use the maximum of filed alignments.
-    alias alignment = classInstanceAlignment!T;
+    enum alignment = __traits(classInstanceAlignment, T);
     alias aligned = _alignUp!alignment;
 
     static struct Scoped
@@ -9418,6 +9418,8 @@ private template replaceTypeInFunctionTypeUnless(alias pred, From, To, fun)
             result ~= " shared";
         static if (attributes & FunctionAttribute.return_)
             result ~= " return";
+        static if (attributes & FunctionAttribute.live)
+            result ~= " @live";
 
         return result;
     }
index a5e2bf4035688da68d8ba93a39cb9cf26272939d..ee2dcee92e4efc212ed127ba1a66e4330318a94d 100644 (file)
@@ -26,7 +26,8 @@ nothrow @nogc:
     {
         import core.stdc.string : memcpy;
 
-        __gshared ubyte[__traits(classInstanceSize, MallocGC)] buf;
+        __gshared align(__traits(classInstanceAlignment, MallocGC))
+            ubyte[__traits(classInstanceSize, MallocGC)] buf;
 
         auto init = typeid(MallocGC).initializer();
         assert(init.length == buf.length);