[committed] d: Reduce code duplication of writing generated files.

2023-10-14 Thread Iain Buclaw
Hi,

This is a small refactoring ahead of the next merge from upstream, where
a few more front-end routines will stop doing the file handling
themselves.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* d-lang.cc (d_write_file): New function.
(d_parse_file): Reduce code duplication.
---
 gcc/d/d-lang.cc | 91 -
 1 file changed, 29 insertions(+), 62 deletions(-)

diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index 7dddcf5ac91..f290acf494b 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -978,6 +978,30 @@ d_add_builtin_module (Module *m)
   builtin_modules.push (m);
 }
 
+/* Writes to FILENAME.  DATA is the full content of the file to be written.  */
+
+static void
+d_write_file (const char *filename, const char *data)
+{
+  FILE *stream;
+
+  if (filename && (filename[0] != '-' || filename[1] != '\0'))
+stream = fopen (filename, "w");
+  else
+stream = stdout;
+
+  if (!stream)
+{
+  error ("unable to open %s for writing: %m", filename);
+  return;
+}
+
+  fprintf (stream, "%s", data);
+
+  if (stream != stdout && (ferror (stream) || fclose (stream)))
+error ("writing output file %s: %m", filename);
+}
+
 /* Implements the lang_hooks.parse_file routine for language D.  */
 
 static void
@@ -1264,8 +1288,6 @@ d_parse_file (void)
   if (d_option.deps)
 {
   obstack buffer;
-  FILE *deps_stream;
-
   gcc_obstack_init (&buffer);
 
   for (size_t i = 0; i < modules.length; i++)
@@ -1275,27 +1297,8 @@ d_parse_file (void)
   if (d_option.deps_filename_user)
d_option.deps_filename = d_option.deps_filename_user;
 
-  if (d_option.deps_filename)
-   {
- deps_stream = fopen (d_option.deps_filename, "w");
- if (!deps_stream)
-   {
- fatal_error (input_location, "opening dependency file %s: %m",
-  d_option.deps_filename);
- goto had_errors;
-   }
-   }
-  else
-   deps_stream = stdout;
-
-  fprintf (deps_stream, "%s", (char *) obstack_finish (&buffer));
-
-  if (deps_stream != stdout
- && (ferror (deps_stream) || fclose (deps_stream)))
-   {
- fatal_error (input_location, "closing dependency file %s: %m",
-  d_option.deps_filename);
-   }
+  d_write_file (d_option.deps_filename,
+   (char *) obstack_finish (&buffer));
 }
 
   if (global.params.vtemplates)
@@ -1306,29 +1309,7 @@ d_parse_file (void)
 {
   OutBuffer buf;
   json_generate (&buf, &modules);
-
-  const char *name = global.params.json.name.ptr;
-  FILE *json_stream;
-
-  if (name && (name[0] != '-' || name[1] != '\0'))
-   {
- const char *nameext
-   = FileName::defaultExt (name, json_ext.ptr);
- json_stream = fopen (nameext, "w");
- if (!json_stream)
-   {
- fatal_error (input_location, "opening json file %s: %m", nameext);
- goto had_errors;
-   }
-   }
-  else
-   json_stream = stdout;
-
-  fprintf (json_stream, "%s", buf.peekChars ());
-
-  if (json_stream != stdout
- && (ferror (json_stream) || fclose (json_stream)))
-   fatal_error (input_location, "closing json file %s: %m", name);
+  d_write_file (global.params.json.name.ptr, buf.peekChars ());
 }
 
   /* Generate Ddoc files.  */
@@ -1391,22 +1372,8 @@ d_parse_file (void)
   /* We want to write the mixin expansion file also on error.  */
   if (global.params.mixinOut.doOutput)
 {
-  FILE *mixin_stream = fopen (global.params.mixinOut.name.ptr, "w");
-
-  if (mixin_stream)
-   {
- 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.mixinOut.name.ptr);
-   }
-  else
-   {
- fatal_error (input_location, "opening mixin file %s: %m",
-  global.params.mixinOut.name.ptr);
-   }
+  d_write_file (global.params.mixinOut.name.ptr,
+   global.params.mixinOut.buffer->peekChars ());
 }
 
   /* Remove generated .di files on error.  */
-- 
2.39.2



[committed] Fix ICE in set_cell_span, at text-art/table.cc:148 with D front-end and -fanalyzer

2023-10-14 Thread Iain Buclaw
Hi,

The internal error in analyzer turned out to be caused by a subtly
invalid tree representation of STRING_CSTs in the D front-end, fixed by
including the terminating NULL as part of the TREE_STRING_POINTER.

When adding a first analyzer test for D, it flagged up another subtle
mismatch in one assignment in the module support routines as well, fixed
by generating the correct field type for the compiler-generated struct.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, and
committed to mainline.

Regards,
Iain.

---
PR d/111537

gcc/d/ChangeLog:

* expr.cc (ExprVisitor::visit (StringExp *)): Include null terminator
in STRING_CST string.
* modules.cc (get_compiler_dso_type): Generate ModuleInfo** type for
the minfo fields.

gcc/testsuite/ChangeLog:

* gdc.dg/analyzer/analyzer.exp: New test.
* gdc.dg/analyzer/pr111537.d: New test.
---
 gcc/d/expr.cc  |  6 +--
 gcc/d/modules.cc   |  9 ++--
 gcc/testsuite/gdc.dg/analyzer/analyzer.exp | 51 ++
 gcc/testsuite/gdc.dg/analyzer/pr111537.d   |  7 +++
 4 files changed, 66 insertions(+), 7 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/analyzer/analyzer.exp
 create mode 100644 gcc/testsuite/gdc.dg/analyzer/pr111537.d

diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index 7038655bc94..551d004c241 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -2535,13 +2535,13 @@ public:
   {
/* Copy the string contents to a null terminated string.  */
dinteger_t length = (e->len * e->sz);
-   char *string = XALLOCAVEC (char, length + 1);
+   char *string = XALLOCAVEC (char, length + e->sz);
+   memset (string, 0, length + e->sz);
if (length > 0)
  memcpy (string, e->string, length);
-   string[length] = '\0';
 
/* String value and type includes the null terminator.  */
-   tree value = build_string (length, string);
+   tree value = build_string (length + e->sz, string);
TREE_TYPE (value) = make_array_type (tb->nextOf (), length + 1);
value = build_address (value);
 
diff --git a/gcc/d/modules.cc b/gcc/d/modules.cc
index f2180d30546..8d6c8f0f9ad 100644
--- a/gcc/d/modules.cc
+++ b/gcc/d/modules.cc
@@ -277,12 +277,13 @@ get_compiler_dso_type (void)
   DECL_CHAIN (field) = fields;
   fields = field;
 
-  field = create_field_decl (build_pointer_type (get_moduleinfo_type ()),
-NULL, 1, 1);
+  tree moduleinfo_ptr_ptr_type =
+build_pointer_type (build_pointer_type (get_moduleinfo_type ()));
+
+  field = create_field_decl (moduleinfo_ptr_ptr_type, NULL, 1, 1);
   DECL_CHAIN (field) = fields;
   fields = field;
-  field = create_field_decl (build_pointer_type (get_moduleinfo_type ()),
-NULL, 1, 1);
+  field = create_field_decl (moduleinfo_ptr_ptr_type, NULL, 1, 1);
   DECL_CHAIN (field) = fields;
   fields = field;
 
diff --git a/gcc/testsuite/gdc.dg/analyzer/analyzer.exp 
b/gcc/testsuite/gdc.dg/analyzer/analyzer.exp
new file mode 100644
index 000..7b82b8e0cd1
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/analyzer/analyzer.exp
@@ -0,0 +1,51 @@
+#  Copyright (C) 2023 Free Software Foundation, Inc.
+
+#  This file is part of GCC.
+#
+#  GCC is free software; you can redistribute it and/or modify it under
+#  the terms of the GNU General Public License as published by the Free
+#  Software Foundation; either version 3, or (at your option) any later
+#  version.
+#
+#  GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
+#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+#  for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with GCC; see the file COPYING3.  If not see
+#  .
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib gdc-dg.exp
+
+# If the analyzer has not been enabled, bail.
+if { ![check_effective_target_analyzer] } {
+return
+}
+
+global DEFAULT_DFLAGS
+if [info exists DEFAULT_DFLAGS] then {
+  set save_default_dflags $DEFAULT_DFLAGS
+}
+
+# If a testcase doesn't have special options, use these.
+set DEFAULT_DFLAGS "-fanalyzer -Wanalyzer-too-complex 
-fanalyzer-call-summaries"
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+gdc-dg-runtest [lsort \
+   [glob -nocomplain $srcdir/$subdir/*.d ] ] "" $DEFAULT_DFLAGS
+
+# All done.
+dg-finish
+
+if [info exists save_default_dflags] {
+  set DEFAULT_DFLAGS $save_default_dflags
+} else {
+  unset DEFAULT_DFLAGS
+}
diff --git a/gcc/testsuite/gdc.dg/analyzer/pr111537.d 
b/gcc/testsuite/gdc.dg/analyzer/pr111537.d
new file mode 100644
index 000..e50b05a3f79
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/analyzer/pr111537.d
@@ -0,0 +1,7 @@
+// { dg-do compile }
+import core.stdc.string;
+void main()
+{
+char[5] arr;
+str

[committed] d: Merge upstream dmd, druntime f9efc98fd7, phobos a3f22129d.

2023-10-15 Thread Iain Buclaw
Hi,

This patch merges the D front-end and run-time library with upstream dmd
f9efc98fd7, and standard library with phobos a3f22129d.

Synchronizing with the latest bug fixes in the v2.105.2 release.

D front-end changes:

- Import dmd v2.105.2.
- A function with enum storage class is now deprecated.
- Global variables can now be initialized with Associative
  Arrays.
- Improvements for the C++ header generation of static variables
  used in a default argument context.

D runtime changes:

- Import druntime v2.105.2.
- The `core.memory.GC' functions `GC.enable', `GC.disable',
  `GC.collect', and `GC.minimize' `have been marked `@safe'.

Phobos changes:

- Import phobos v2.105.2.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd f9efc98fd7.
* dmd/VERSION: Bump version to v2.105.2.
* d-builtins.cc (build_frontend_type): Update for new front-end
interface.
* d-diagnostic.cc (verrorReport): Don't emit tips when error gagging
is turned on.
* d-lang.cc (d_handle_option): Remove obsolete parameter.
(d_post_options): Likewise.
(d_read_ddoc_files): New function.
(d_generate_ddoc_file): New function.
(d_parse_file): Update for new front-end interface.
* expr.cc (ExprVisitor::visit (AssocArrayLiteralExp *)): Check for new
front-end lowering of static associative arrays.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime f9efc98fd7.
* libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add
core/internal/newaa.d.
* libdruntime/Makefile.in: Regenerate.
* src/MERGE: Merge upstream phobos a3f22129d.
* testsuite/libphobos.hash/test_hash.d: Update test.
* testsuite/libphobos.phobos/phobos.exp: Add compiler flags
-Wno-deprecated.
* testsuite/libphobos.phobos_shared/phobos_shared.exp: Likewise.

gcc/testsuite/ChangeLog:

* lib/gdc-utils.exp (gdc-convert-args): Handle new compiler options.
---
 gcc/d/d-builtins.cc   |   3 +-
 gcc/d/d-diagnostic.cc |   5 +-
 gcc/d/d-lang.cc   |  78 +++-
 gcc/d/dmd/MERGE   |   2 +-
 gcc/d/dmd/VERSION |   2 +-
 gcc/d/dmd/attrib.d|   2 +-
 gcc/d/dmd/blockexit.d | 107 +++--
 gcc/d/dmd/canthrow.d  |   2 +-
 gcc/d/dmd/chkformat.d |  32 +-
 gcc/d/dmd/clone.d |  20 +-
 gcc/d/dmd/cond.d  |   2 +-
 gcc/d/dmd/cparse.d|  11 +-
 gcc/d/dmd/cppmangle.d |   2 -
 gcc/d/dmd/ctfeexpr.d  |   6 +-
 gcc/d/dmd/dcast.d |  13 +-
 gcc/d/dmd/dclass.d|   6 +-
 gcc/d/dmd/declaration.d   |   7 +-
 gcc/d/dmd/delegatize.d|   1 -
 gcc/d/dmd/denum.d |   2 -
 gcc/d/dmd/dinterpret.d|  14 +-
 gcc/d/dmd/dmacro.d|  56 ++-
 gcc/d/dmd/dmodule.d   |   4 +-
 gcc/d/dmd/doc.d   | 353 -
 gcc/d/dmd/doc.h   |   3 +-
 gcc/d/dmd/dscope.d|   1 +
 gcc/d/dmd/dstruct.d   |   1 +
 gcc/d/dmd/dsymbol.d   |   1 +
 gcc/d/dmd/dsymbolsem.d|  58 ++-
 gcc/d/dmd/dtemplate.d |  24 +-
 gcc/d/dmd/dtoh.d  |  10 +-
 gcc/d/dmd/errors.h|   3 +-
 gcc/d/dmd/errorsink.d |   1 +
 gcc/d/dmd/escape.d|  40 +-
 gcc/d/dmd/expression.d|  47 ++-
 gcc/d/dmd/expression.h|   3 +-
 gcc/d/dmd/expressionsem.d | 109 ++---
 gcc/d/dmd/func.d  |  21 +-
 gcc/d/dmd/globals.d   |  33 +-
 gcc/d/dmd/globals.h   |  35 +-
 gcc/d/dmd/hdrgen.d| 375 +-
 gcc/d/dmd/hdrgen.h|   4 +-
 gcc/d/dmd/iasmgcc.d   |   2 +-
 gcc/d/dmd/id.d|   2 +
 gcc/d/dmd/init.d  |   2 +-
 gcc/d/dmd/initsem.d   |  31 +-
 gcc/d/dmd/json.d  |  23 +-
 gcc/d/dmd/json.h  |   2 +-
 gcc/d/dmd/lexer.d |  88 +++-
 gcc/d/dmd/location.d  |  20 +-
 gcc/d/dmd/module.h

[committed] d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.

2023-10-16 Thread Iain Buclaw
Hi,

This patch merges the D front-end and run-time library with upstream dmd
4c18eed967, and standard library with phobos d945686a4.

Synchronizing with the upstream development branch as of 2023-10-16.

D front-end changes:

- Import latest fixes to mainline.

D runtime changes:

- Import latest fixes to mainline.

Phobos changes:

- Import latest fixes to mainline.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 4c18eed967.
* d-diagnostic.cc (verrorReport): Update for new front-end interface.
(verrorReportSupplemental): Likewise.
* d-lang.cc (d_init_options): Likewise.
(d_handle_option): Likewise.
(d_post_options): Likewise.
(d_parse_file): Likewise.
* decl.cc (get_symbol_decl): Likewise.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 4c18eed967.
* src/MERGE: Merge upstream phobos d945686a4.
---
 gcc/d/d-diagnostic.cc |   4 +-
 gcc/d/d-lang.cc   |  86 +-
 gcc/d/decl.cc |   4 +-
 gcc/d/dmd/MERGE   |   2 +-
 gcc/d/dmd/access.d|   3 +-
 gcc/d/dmd/aggregate.d |  11 +-
 gcc/d/dmd/aggregate.h |   1 +
 gcc/d/dmd/arrayop.d   |  11 +-
 gcc/d/dmd/attrib.d|   7 +-
 gcc/d/dmd/blockexit.d |  19 +-
 gcc/d/dmd/canthrow.d  |  43 +-
 gcc/d/dmd/clone.d |   2 +-
 gcc/d/dmd/compiler.d  |   1 -
 gcc/d/dmd/cond.d  |   4 +
 gcc/d/dmd/constfold.d |  18 +-
 gcc/d/dmd/cparse.d|   5 +-
 gcc/d/dmd/cppmangle.d |  10 +-
 gcc/d/dmd/ctfe.h  |   1 -
 gcc/d/dmd/ctfeexpr.d  |   8 +-
 gcc/d/dmd/dcast.d |  53 +-
 gcc/d/dmd/dclass.d|  58 +-
 gcc/d/dmd/declaration.d   |  16 +-
 gcc/d/dmd/denum.d |   5 +-
 gcc/d/dmd/dimport.d   |   2 +-
 gcc/d/dmd/dinterpret.d| 296 +++
 gcc/d/dmd/dmangle.d   |  20 +-
 gcc/d/dmd/dmodule.d   |  44 +-
 gcc/d/dmd/doc.d   |   2 +-
 gcc/d/dmd/dstruct.d   |   2 +-
 gcc/d/dmd/dsymbol.d   |  87 +-
 gcc/d/dmd/dsymbol.h   |   4 -
 gcc/d/dmd/dsymbolsem.d| 306 +++
 gcc/d/dmd/dtemplate.d |  69 +-
 gcc/d/dmd/dtoh.d  |  20 +
 gcc/d/dmd/dversion.d  |  13 +-
 gcc/d/dmd/expression.d| 336 +++-
 gcc/d/dmd/expression.h|   6 +-
 gcc/d/dmd/expressionsem.d | 439 +-
 gcc/d/dmd/func.d  |  36 +-
 gcc/d/dmd/globals.d   |  57 +-
 gcc/d/dmd/globals.h   |  48 +-
 gcc/d/dmd/hdrgen.d| 760 ++
 gcc/d/dmd/iasm.d  |   1 +
 gcc/d/dmd/id.d|   2 +
 gcc/d/dmd/importc.d   |   5 +-
 gcc/d/dmd/init.d  |   8 -
 gcc/d/dmd/init.h  |   2 -
 gcc/d/dmd/initsem.d   |  31 +-
 gcc/d/dmd/json.d  |   4 +-
 gcc/d/dmd/lexer.d |  75 +-
 gcc/d/dmd/mtype.d |   6 +-
 gcc/d/dmd/mustuse.d   |   3 +-
 gcc/d/dmd/nogc.d  |   4 +-
 gcc/d/dmd/nspace.d|   3 +-
 gcc/d/dmd/ob.d|  20 +-
 gcc/d/dmd/objc.d  |  32 +-
 gcc/d/dmd/opover.d|  32 +-
 gcc/d/dmd/optimize.d  |  53 +-
 gcc/d/dmd/parse.d |  15 +-
 gcc/d/dmd/root/filename.d |   7 +-
 gcc/d/dmd/root/rootobject.d   |   6 +-
 gcc/d/dmd/semantic2.d |  34 +-
 gcc/d/dmd/semantic3.d |  48 +-
 gcc/d/dmd/sideeffect.d|   9 +-
 gcc/d/dmd/statement.d | 167 +---
 gcc/d/dmd/statement.h |   8 +-
 gcc/d/dmd/statementsem.d  | 192 -
 gcc/d/dmd/staticcond.d|   3 +-
 gcc/d/dmd/traits.d| 104 +--
 gcc/d/dmd/typesem.d   |  42 +-

[committed] d: Forbid taking the address of an intrinsic with no implementation

2023-10-16 Thread Iain Buclaw
Hi,

This code fails to link:

import core.math;
real function(real) fn = &sin;

However, when called directly, the D intrinsic `sin()' is expanded by
the front-end into the GCC built-in `__builtin_sin()'.  This has been
fixed to now also expand the function when a reference is taken.

As there are D intrinsics and GCC built-ins that don't have a fallback
implementation, raise an error if taking the address is not possible.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, and
committed to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* d-tree.h (intrinsic_code): Update define for DEF_D_INTRINSIC.
(maybe_reject_intrinsic): New prototype.
* expr.cc (ExprVisitor::visit (SymOffExp *)): Call
maybe_reject_intrinsic.
* intrinsics.cc (intrinsic_decl): Add fallback field.
(intrinsic_decls): Update define for DEF_D_INTRINSIC.
(maybe_reject_intrinsic): New function.
* intrinsics.def (DEF_D_LIB_BUILTIN): Update.
(DEF_CTFE_BUILTIN): Update.
(INTRINSIC_BSF): Declare as library builtin.
(INTRINSIC_BSR): Likewise.
(INTRINSIC_BT): Likewise.
(INTRINSIC_BSF64): Likewise.
(INTRINSIC_BSR64): Likewise.
(INTRINSIC_BT64): Likewise.
(INTRINSIC_POPCNT32): Likewise.
(INTRINSIC_POPCNT64): Likewise.
(INTRINSIC_ROL): Likewise.
(INTRINSIC_ROL_TIARG): Likewise.
(INTRINSIC_ROR): Likewise.
(INTRINSIC_ROR_TIARG): Likewise.
(INTRINSIC_ADDS): Likewise.
(INTRINSIC_ADDSL): Likewise.
(INTRINSIC_ADDU): Likewise.
(INTRINSIC_ADDUL): Likewise.
(INTRINSIC_SUBS): Likewise.
(INTRINSIC_SUBSL): Likewise.
(INTRINSIC_SUBU): Likewise.
(INTRINSIC_SUBUL): Likewise.
(INTRINSIC_MULS): Likewise.
(INTRINSIC_MULSL): Likewise.
(INTRINSIC_MULU): Likewise.
(INTRINSIC_MULUI): Likewise.
(INTRINSIC_MULUL): Likewise.
(INTRINSIC_NEGS): Likewise.
(INTRINSIC_NEGSL): Likewise.
(INTRINSIC_TOPRECF): Likewise.
(INTRINSIC_TOPREC): Likewise.
(INTRINSIC_TOPRECL): Likewise.

gcc/testsuite/ChangeLog:

* gdc.dg/builtins_reject.d: New test.
* gdc.dg/intrinsics_reject.d: New test.
---
 gcc/d/d-tree.h   |   3 +-
 gcc/d/expr.cc|   3 +
 gcc/d/intrinsics.cc  |  47 -
 gcc/d/intrinsics.def | 128 ---
 gcc/testsuite/gdc.dg/builtins_reject.d   |  17 +++
 gcc/testsuite/gdc.dg/intrinsics_reject.d |  87 +++
 6 files changed, 222 insertions(+), 63 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/builtins_reject.d
 create mode 100644 gcc/testsuite/gdc.dg/intrinsics_reject.d

diff --git a/gcc/d/d-tree.h b/gcc/d/d-tree.h
index b64a6fb46f9..66c2f2465c8 100644
--- a/gcc/d/d-tree.h
+++ b/gcc/d/d-tree.h
@@ -94,7 +94,7 @@ enum level_kind
 
 enum intrinsic_code
 {
-#define DEF_D_INTRINSIC(CODE, B, N, M, D, C) CODE,
+#define DEF_D_INTRINSIC(CODE, B, N, M, D, C, F) CODE,
 
 #include "intrinsics.def"
 
@@ -668,6 +668,7 @@ extern tree build_import_decl (Dsymbol *);
 /* In intrinsics.cc.  */
 extern void maybe_set_intrinsic (FuncDeclaration *);
 extern tree maybe_expand_intrinsic (tree);
+extern tree maybe_reject_intrinsic (tree);
 
 /* In modules.cc.  */
 extern void build_module_tree (Module *);
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index cc4aa03dfb9..52243e61899 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -2050,6 +2050,9 @@ public:
 tree result = get_decl_tree (e->var);
 TREE_USED (result) = 1;
 
+if (e->var->isFuncDeclaration ())
+  result = maybe_reject_intrinsic (result);
+
 if (declaration_reference_p (e->var))
   gcc_assert (POINTER_TYPE_P (TREE_TYPE (result)));
 else
diff --git a/gcc/d/intrinsics.cc b/gcc/d/intrinsics.cc
index 583d5a9dea6..1b03e9edbdb 100644
--- a/gcc/d/intrinsics.cc
+++ b/gcc/d/intrinsics.cc
@@ -60,12 +60,15 @@ struct intrinsic_decl
 
   /* True if the intrinsic is only handled in CTFE.  */
   bool ctfeonly;
+
+  /* True if the intrinsic has a library implementation.  */
+  bool fallback;
 };
 
 static const intrinsic_decl intrinsic_decls[] =
 {
-#define DEF_D_INTRINSIC(CODE, BUILTIN, NAME, MODULE, DECO, CTFE) \
-{ CODE, BUILTIN, NAME, MODULE, DECO, CTFE },
+#define DEF_D_INTRINSIC(CODE, BUILTIN, NAME, MODULE, DECO, CTFE, FALLBACK) \
+{ CODE, BUILTIN, NAME, MODULE, DECO, CTFE, FALLBACK },
 
 #include "intrinsics.def"
 
@@ -1436,3 +1439,43 @@ maybe_expand_intrinsic (tree callexp)
   gcc_unreachable ();
 }
 }
+
+/* If FNDECL is an intrinsic, return the FUNCTION_DECL that has a library
+   fallback implementation of it, otherwise raise an error.  */
+
+tree
+maybe_reject_intrinsic (tree fndecl)
+{
+  gcc_assert (TREE_CODE (fndecl) == FUNCTION_DECL);
+
+  intrinsic_code intrinsic = DECL_INTRINSIC_CODE (fndecl);
+
+  if (intrinsic == INTRINSIC_NONE)
+{

[PATCH] libbacktrace: Move define of HAVE_ZLIB into check for -lz

2018-07-29 Thread Iain Buclaw
This is really to suppress the default action-if-found for
AC_CHECK_LIBS.  Zlib is not a dependency of libbacktrace, and so it
shouldn't be added to LIBS.  When looking at the check, saw that could
remove the test for ac_cv_lib_z_compress also.

Regards
Iain
---
2018-07-29 Iain Buclaw  

	* configure.ac: Move define of HAVE_ZLIB into check for -lz.
	* Makefile.in: Regenerate.
	* config.h.in: Likewise.
	* configure: Likewise.

diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in
index f7f849bdeaf..8b5dc3e5b41 100644
--- a/libbacktrace/Makefile.in
+++ b/libbacktrace/Makefile.in
@@ -16,7 +16,7 @@
 @SET_MAKE@
 
 # Makefile.am -- Backtrace Makefile.
-# Copyright (C) 2012-2017 Free Software Foundation, Inc.
+# Copyright (C) 2012-2018 Free Software Foundation, Inc.
 
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
diff --git a/libbacktrace/config.h.in b/libbacktrace/config.h.in
index c19b6e430cb..6205fc55fa5 100644
--- a/libbacktrace/config.h.in
+++ b/libbacktrace/config.h.in
@@ -34,9 +34,6 @@
 /* Define to 1 if you have the  header file. */
 #undef HAVE_INTTYPES_H
 
-/* Define to 1 if you have the `z' library (-lz). */
-#undef HAVE_LIBZ
-
 /* Define to 1 if you have the  header file. */
 #undef HAVE_LINK_H
 
diff --git a/libbacktrace/configure b/libbacktrace/configure
index 87cadda6c8c..d5a9d79e15c 100755
--- a/libbacktrace/configure
+++ b/libbacktrace/configure
@@ -12973,19 +12973,11 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_compress" >&5
 $as_echo "$ac_cv_lib_z_compress" >&6; }
 if test "x$ac_cv_lib_z_compress" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBZ 1
-_ACEOF
-
-  LIBS="-lz $LIBS"
-
-fi
-
-if test $ac_cv_lib_z_compress = "yes"; then
 
 $as_echo "#define HAVE_ZLIB 1" >>confdefs.h
 
 fi
+
  if test "$ac_cv_lib_z_compress" = yes; then
   HAVE_ZLIB_TRUE=
   HAVE_ZLIB_FALSE='#'
diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac
index 6f7b5eabca6..fd367451602 100644
--- a/libbacktrace/configure.ac
+++ b/libbacktrace/configure.ac
@@ -426,10 +426,8 @@ AC_SUBST(PTHREAD_CFLAGS)
 
 AM_CONDITIONAL(HAVE_PTHREAD, test "$libgo_cv_lib_pthread" = yes)
 
-AC_CHECK_LIB([z], [compress], [])
-if test $ac_cv_lib_z_compress = "yes"; then
-  AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.])
-fi
+AC_CHECK_LIB([z], [compress],
+[AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.])])
 AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_lib_z_compress" = yes)
 
 dnl Test whether the linker supports the --compress_debug_sections option.


[PATCH] Move -Walloca and related warnings from c.opt to common.opt

2018-07-29 Thread Iain Buclaw
Hi,

Since r262910, it was noticed that new -Walloca-larger-than= warnings
started appearing when building the D frontend's standard library.
These have been checked and verified as valid, and appropriate fixes
will be sent on upstream.

As for the warning itself, as it is now default on, it would be
preferable to be able control it.  Given the choice between adding
these options to the D frontend or moving them to common, I'd rather
move them to common.

Regards
Iain.

---
gcc/ChangeLog

	* common.opt (-Walloca): Moved from common.opt.
	(Walloca-larger-than=): Likewise.
	(Wno-alloca-larger-than): Likewise.

gcc/c-family/ChangeLog

	* c.opt (-Walloca): Move to common.opt.
	(Walloca-larger-than=): Likewise.
	(Wno-alloca-larger-than): Likewise.

diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index d6148380710..67da5a9e401 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -299,10 +299,6 @@ Wall
 C ObjC C++ ObjC++ Warning
Enable most warning messages.
 
-Walloca
-C ObjC C++ ObjC++ Var(warn_alloca) Warning
-Warn on any use of alloca.
-
 Walloc-size-larger-than=
 C ObjC C++ LTO ObjC++ Var(warn_alloc_size_limit) Joined Host_Wide_Int ByteSize Warning Init(HOST_WIDE_INT_MAX)
 -Walloc-size-larger-than= Warn for calls to allocation functions that
@@ -316,16 +312,6 @@ Walloc-zero
 C ObjC C++ ObjC++ Var(warn_alloc_zero) Warning
 -Walloc-zero Warn for calls to allocation functions that specify zero bytes.
 
-Walloca-larger-than=
-C ObjC C++ LTO ObjC++ Var(warn_alloca_limit) Warning Joined Host_Wide_Int ByteSize Init(HOST_WIDE_INT_MAX)
--Walloca-larger-than=	Warn on unbounded uses of
-alloca, and on bounded uses of alloca whose bound can be larger than
- bytes.
-
-Wno-alloca-larger-than
-C ObjC C++ LTO ObjC++ Alias(Walloca-larger-than=,18446744073709551615EiB,none) Warning
--Wno-alloca-larger-than Disable Walloca-larger-than= warning.  Equivalent to Walloca-larger-than= or larger.
-
 Warray-bounds
 LangEnabledBy(C ObjC C++ LTO ObjC++)
 ; in common.opt
diff --git a/gcc/common.opt b/gcc/common.opt
index 4bf8de90331..fa68eda4213 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -538,6 +538,20 @@ Waggressive-loop-optimizations
 Common Var(warn_aggressive_loop_optimizations) Init(1) Warning
 Warn if a loop with constant number of iterations triggers undefined behavior.
 
+Walloca
+Common Var(warn_alloca) Warning
+Warn on any use of alloca.
+
+Walloca-larger-than=
+Common Var(warn_alloca_limit) Warning Joined Host_Wide_Int ByteSize Init(HOST_WIDE_INT_MAX)
+-Walloca-larger-than=	Warn on unbounded uses of
+alloca, and on bounded uses of alloca whose bound can be larger than
+ bytes.
+
+Wno-alloca-larger-than
+Common Alias(Walloca-larger-than=,18446744073709551615EiB,none) Warning
+-Wno-alloca-larger-than Disable Walloca-larger-than= warning.  Equivalent to Walloca-larger-than= or larger.
+
 Warray-bounds
 Common Var(warn_array_bounds) Warning
 Warn if an array is accessed out of bounds.


Re: [PATCH] Move -Walloca and related warnings from c.opt to common.opt

2018-07-30 Thread Iain Buclaw
On 30 July 2018 at 17:45, Martin Sebor  wrote:
> On 07/30/2018 09:28 AM, Jakub Jelinek wrote:
>>
>> On Sun, Jul 29, 2018 at 08:35:39PM +0200, Iain Buclaw wrote:
>>>
>>> Since r262910, it was noticed that new -Walloca-larger-than= warnings
>>> started appearing when building the D frontend's standard library.
>>> These have been checked and verified as valid, and appropriate fixes
>>> will be sent on upstream.
>>>
>>> As for the warning itself, as it is now default on, it would be
>>> preferable to be able control it.  Given the choice between adding
>>> these options to the D frontend or moving them to common, I'd rather
>>> move them to common.
>>
>>
>> It is strange to add a warning option for languages that don't even have
>> alloca.  Instead, the warning shouldn't be enabled by default (but Martin
>> doesn't want to listen to that), or at least should be enabled only for
>> the
>> languages where it makes sense.
>
>
> I agree that the warning shouldn't be enabled for languages that
> don't have support for alloca.
>

Fair enough, I'll add them to D instead then.

I am curious though if its possible to trigger warnings from languages
that don't have direct support for alloca.  However having a look, the
only places that generate a call to alloca deal with variable-sized
objects.

Iain.


Re: [PATCH] libbacktrace: Move define of HAVE_ZLIB into check for -lz

2018-07-31 Thread Iain Buclaw
On 31 July 2018 at 16:33, Ian Lance Taylor  wrote:
> On Sun, Jul 29, 2018 at 7:50 AM, Iain Buclaw  wrote:
>>
>> This is really to suppress the default action-if-found for
>> AC_CHECK_LIBS.  Zlib is not a dependency of libbacktrace, and so it
>> shouldn't be added to LIBS.  When looking at the check, saw that could
>> remove the test for ac_cv_lib_z_compress also.
>
> Thanks, but this doesn't seem like quite the right approach, as seen
> by the fact that HAVE_ZLIB_H was dropped from config.h.in.  I think
> you need to keep the AC_DEFINE out of the AC_CHECK_LIB.  I would guess
> that it would work to just change the default case of AC_CHECK_LIB to
> [;] or something similarly innocuous.
>
> Ian

May I ask you to look at the patch again?  There's two similarly named
variables here, HAVE_LIBZ and HAVE_ZLIB.

Only the unused HAVE_LIBZ has been dropped from config.h.in.  The one
that matters has been left alone, or at least I'm pretty sure of.

Iain.


[committed] d: Merge upstream dmd f4be7f6f7b.

2023-10-22 Thread Iain Buclaw
Hi,

This patch merges the D front-end with upstream dmd f4be7f6f7b.

Synchronizing with the upstream development branch as of 2023-10-22.

D front-end changes:

- Fix bootstrap failure with i686-darwin9.
  ```
  Undefined symbols for architecture i386:
  "gendocfile", referenced from:
  __ZL20d_generate_ddoc_fileP6ModuleR9OutBuffer in d-lang.o
  ld: symbol(s) not found for architecture i386
  ```

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd f4be7f6f7b.
* Make-lang.in (D_FRONTEND_OBJS): Rename d/root-rootobject.o to
d/rootobject.o.
---
 gcc/d/Make-lang.in|   2 +-
 gcc/d/dmd/MERGE   |   2 +-
 gcc/d/dmd/README.md   |   1 +
 gcc/d/dmd/arraytypes.d|   2 +-
 gcc/d/dmd/ast_node.d  |   2 +-
 gcc/d/dmd/blockexit.d |  20 +-
 gcc/d/dmd/cond.d  |   2 +-
 gcc/d/dmd/cppmangle.d |   2 +-
 gcc/d/dmd/declaration.d   |   2 +-
 gcc/d/dmd/dinterpret.d|  18 +-
 gcc/d/dmd/dmodule.d   |   2 +-
 gcc/d/dmd/doc.h   |   4 +-
 gcc/d/dmd/dscope.d|   6 -
 gcc/d/dmd/dsymbol.d   |   2 +-
 gcc/d/dmd/dsymbolsem.d|   8 +-
 gcc/d/dmd/dtemplate.d |   2 +-
 gcc/d/dmd/dtoh.d  |   2 +-
 gcc/d/dmd/escape.d|   2 +-
 gcc/d/dmd/expression.d| 284 +
 gcc/d/dmd/expression.h|   1 -
 gcc/d/dmd/expressionsem.d | 300 --
 gcc/d/dmd/foreachvar.d|   2 +-
 gcc/d/dmd/func.d  |  12 +-
 gcc/d/dmd/hdrgen.d|   2 +-
 gcc/d/dmd/identifier.d|   2 +-
 gcc/d/dmd/init.d  |   2 +-
 gcc/d/dmd/json.d  |   2 +-
 gcc/d/dmd/mtype.d |   2 +-
 gcc/d/dmd/mustuse.d   |  23 +-
 gcc/d/dmd/nogc.d  |   2 +-
 gcc/d/dmd/ob.d|   2 +-
 gcc/d/dmd/parse.d |   2 +-
 gcc/d/dmd/{root => }/rootobject.d |   8 +-
 gcc/d/dmd/semantic2.d |   2 +-
 gcc/d/dmd/semantic3.d |   2 +-
 gcc/d/dmd/sideeffect.d|  35 --
 gcc/d/dmd/statement.d |   2 +-
 gcc/d/dmd/statement.h |   3 -
 gcc/d/dmd/templateparamsem.d  |   2 +-
 gcc/d/dmd/traits.d|   2 +-
 gcc/d/dmd/transitivevisitor.d |   2 +-
 gcc/d/dmd/typesem.d   |   2 +-
 gcc/d/dmd/visitor.d   |   2 +-
 .../gdc.test/fail_compilation/fail3882.d  |  31 +-
 gcc/testsuite/gdc.test/runnable/issue24168.d  |  31 ++
 45 files changed, 375 insertions(+), 468 deletions(-)
 rename gcc/d/dmd/{root => }/rootobject.d (88%)
 create mode 100644 gcc/testsuite/gdc.test/runnable/issue24168.d

diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
index 264ae03a89e..b3007a96bd0 100644
--- a/gcc/d/Make-lang.in
+++ b/gcc/d/Make-lang.in
@@ -174,11 +174,11 @@ D_FRONTEND_OBJS = \
d/root-port.o \
d/root-region.o \
d/root-rmem.o \
-   d/root-rootobject.o \
d/root-speller.o \
d/root-string.o \
d/root-stringtable.o \
d/root-utf.o \
+   d/rootobject.o \
d/safe.o \
d/sapply.o \
d/semantic2.o \
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 794600274a3..bfadeaa0c68 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-4c18eed9674e04c1ca89fbc8bd5c4e483eb5477c
+f4be7f6f7bae75f1613b862940cdd533b5ae99b2
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/README.md b/gcc/d/dmd/README.md
index d0c75a5b14a..f8ac00117eb 100644
--- a/gcc/d/dmd/README.md
+++ b/gcc/d/dmd/README.md
@@ -84,6 +84,7 @@
 | 
[astcodegen.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/astcodegen.d)
 | Namespace of AST nodes of a AST ready for code generation   |
 | 
[astenums.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/astenums.d)
 | Enums common to DMD and AST |
 | 
[expression.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/expression.d)
 | Define expression AST nodes |
+| 
[rootobject.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/rootobject.d)
 | D

[committed] d: Add warning for call expression without side effects

2023-10-28 Thread Iain Buclaw
Hi,

In the last merge of the dmd front-end with upstream (r14-4830), this
warning got removed from the semantic passes.  Reimplement the warning
for the code generation pass instead, where it cannot have an effect on
conditional compilation.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* d-codegen.cc (call_side_effect_free_p): New function.
* d-tree.h (CALL_EXPR_WARN_IF_UNUSED): New macro.
(call_side_effect_free_p): New prototype.
* expr.cc (ExprVisitor::visit (CallExp *)): Set
CALL_EXPR_WARN_IF_UNUSED on matched call expressions.
(ExprVisitor::visit (NewExp *)): Don't dereference the result of an
allocation call here.
* toir.cc (add_stmt): Emit warning when call expression added to
statement list without being used.

gcc/testsuite/ChangeLog:

* gdc.dg/Wunused_value.d: New test.
---
 gcc/d/d-codegen.cc   | 54 
 gcc/d/d-tree.h   |  7 
 gcc/d/expr.cc| 13 ++-
 gcc/d/toir.cc| 32 +
 gcc/testsuite/gdc.dg/Wunused_value.d | 29 +++
 5 files changed, 134 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gdc.dg/Wunused_value.d

diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 155f5d0d618..8c2e6c70ed4 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -2102,6 +2102,60 @@ get_function_type (Type *t)
   return tf;
 }
 
+/* Returns TRUE if calling the function FUNC, or the function or delegate type
+   TYPE is free of side effects.  */
+
+bool
+call_side_effect_free_p (FuncDeclaration *func, Type *type)
+{
+  gcc_assert (func != NULL || type != NULL);
+
+  if (func != NULL)
+{
+  /* Constructor and invariant calls can't be `pure'.  */
+  if (func->isCtorDeclaration () || func->isInvariantDeclaration ())
+   return false;
+
+  /* Must be a `nothrow' function.  */
+  TypeFunction *tf = func->type->toTypeFunction ();
+  if (!tf->isnothrow ())
+   return false;
+
+  /* Return type can't be `void' or `noreturn', as that implies all work is
+done via side effects.  */
+  if (tf->next->ty == TY::Tvoid || tf->next->ty == TY::Tnoreturn)
+   return false;
+
+  /* Only consider it as `pure' if it can't modify its arguments.  */
+  if (func->isPure () == PURE::const_)
+   return true;
+}
+
+  if (type != NULL)
+{
+  TypeFunction *tf = get_function_type (type);
+
+  /* Must be a `nothrow` function type.  */
+  if (tf == NULL || !tf->isnothrow ())
+   return false;
+
+  /* Return type can't be `void' or `noreturn', as that implies all work is
+done via side effects.  */
+  if (tf->next->ty == TY::Tvoid || tf->next->ty == TY::Tnoreturn)
+   return false;
+
+  /* Delegates that can modify its context can't be `pure'.  */
+  if (type->isTypeDelegate () && tf->isMutable ())
+   return false;
+
+  /* Only consider it as `pure' if it can't modify its arguments.  */
+  if (tf->purity == PURE::const_)
+   return true;
+}
+
+  return false;
+}
+
 /* Returns TRUE if CALLEE is a plain nested function outside the scope of
CALLER.  In which case, CALLEE is being called through an alias that was
passed to CALLER.  */
diff --git a/gcc/d/d-tree.h b/gcc/d/d-tree.h
index 66c2f2465c8..ed26533feb4 100644
--- a/gcc/d/d-tree.h
+++ b/gcc/d/d-tree.h
@@ -47,6 +47,7 @@ typedef Array  Expressions;
 
 /* Usage of TREE_LANG_FLAG_?:
0: METHOD_CALL_EXPR
+   1: CALL_EXPR_WARN_IF_UNUSED (in CALL_EXPR).
 
Usage of TYPE_LANG_FLAG_?:
0: TYPE_SHARED
@@ -357,6 +358,11 @@ lang_tree_node
 #define METHOD_CALL_EXPR(NODE) \
   (TREE_LANG_FLAG_0 (NODE))
 
+/* True if the CALL_EXPR is free of side effects, and its return value
+   should not be discarded.  */
+#define CALL_EXPR_WARN_IF_UNUSED(NODE) \
+  (TREE_LANG_FLAG_1 (CALL_EXPR_CHECK (NODE)))
+
 /* True if the type was declared 'shared'.  */
 #define TYPE_SHARED(NODE) \
   (TYPE_LANG_FLAG_0 (NODE))
@@ -594,6 +600,7 @@ extern tree build_bounds_slice_condition (SliceExp *, tree, 
tree, tree);
 extern bool array_bounds_check (void);
 extern bool checkaction_trap_p (void);
 extern TypeFunction *get_function_type (Type *);
+extern bool call_side_effect_free_p (FuncDeclaration *, Type *);
 extern bool call_by_alias_p (FuncDeclaration *, FuncDeclaration *);
 extern tree d_build_call_expr (FuncDeclaration *, tree, Expressions *);
 extern tree d_build_call (TypeFunction *, tree, tree, Expressions *);
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index 52243e61899..72180b100af 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -1714,6 +1714,12 @@ public:
build the call expression.  */
 tree exp = d_build_call (tf, callee, object, e->arguments);
 
+/* Record whether the call expression has no side effects, so we can check
+   for an 

[committed] d: Fix ICE: in verify_gimple_in_seq on powerpc-darwin9 [PR112270]

2023-10-28 Thread Iain Buclaw
Hi,

This patch fixes an ICE seen during stage2 on powerpc-darwin9 only.
There were still some uses of GCC's boolean_type_node in the D
front-end, which caused a type mismatch to trigger as D bool size is
fixed to 1 byte on all targets.

So two new nodes have been introduced - d_bool_false_node and
d_bool_true_node - which have replaced all remaining uses of
boolean_false_node and boolean_true_node respectively.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline, and backported to gcc-12 and gcc-13.

Regards,
Iain.

---
PR d/112270

gcc/d/ChangeLog:

* d-builtins.cc (d_build_d_type_nodes): Initialize d_bool_false_node,
d_bool_true_node.
* d-codegen.cc (build_array_struct_comparison): Use d_bool_false_node
instead of boolean_false_node.
* d-convert.cc (d_truthvalue_conversion): Use d_bool_false_node and
d_bool_true_node instead of boolean_false_node and boolean_true_node.
* d-tree.h (enum d_tree_index): Add DTI_BOOL_FALSE and DTI_BOOL_TRUE.
(d_bool_false_node): New macro.
(d_bool_true_node): New macro.
* modules.cc (build_dso_cdtor_fn): Use d_bool_false_node and
d_bool_true_node instead of boolean_false_node and boolean_true_node.
(register_moduleinfo): Use d_bool_type instead of boolean_type_node.

gcc/testsuite/ChangeLog:

* gdc.dg/pr112270.d: New test.
---
 gcc/d/d-builtins.cc |  3 +++
 gcc/d/d-codegen.cc  |  2 +-
 gcc/d/d-convert.cc  | 10 +-
 gcc/d/d-tree.h  |  6 ++
 gcc/d/modules.cc|  4 ++--
 gcc/testsuite/gdc.dg/pr112270.d |  7 +++
 6 files changed, 24 insertions(+), 8 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/pr112270.d

diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc
index cf998d22721..f6ea026bdcf 100644
--- a/gcc/d/d-builtins.cc
+++ b/gcc/d/d-builtins.cc
@@ -956,6 +956,9 @@ d_build_d_type_nodes (void)
   d_bool_type = make_unsigned_type (1);
   TREE_SET_CODE (d_bool_type, BOOLEAN_TYPE);
 
+  d_bool_false_node = TYPE_MIN_VALUE (d_bool_type);
+  d_bool_true_node = TYPE_MAX_VALUE (d_bool_type);
+
   char8_type_node = make_unsigned_type (8);
   TYPE_STRING_FLAG (char8_type_node) = 1;
 
diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 91ddb1b657e..270cb5e2be6 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -1115,7 +1115,7 @@ build_array_struct_comparison (tree_code code, 
StructDeclaration *sd,
if (length == 0 || result OP 0) break;  */
   t = build_boolop (EQ_EXPR, length, d_convert (lentype, integer_zero_node));
   t = build_boolop (TRUTH_ORIF_EXPR, t, build_boolop (code, result,
- boolean_false_node));
+ d_bool_false_node));
   t = build1 (EXIT_EXPR, void_type_node, t);
   add_stmt (t);
 
diff --git a/gcc/d/d-convert.cc b/gcc/d/d-convert.cc
index 2b9d8e78fb6..71d7a41374e 100644
--- a/gcc/d/d-convert.cc
+++ b/gcc/d/d-convert.cc
@@ -132,13 +132,13 @@ d_truthvalue_conversion (tree expr)
   return expr;
 
 case INTEGER_CST:
-  return integer_zerop (expr) ? boolean_false_node
- : boolean_true_node;
+  return integer_zerop (expr) ? d_bool_false_node
+ : d_bool_true_node;
 
 case REAL_CST:
   return real_compare (NE_EXPR, &TREE_REAL_CST (expr), &dconst0)
-? boolean_true_node
-: boolean_false_node;
+? d_bool_true_node
+: d_bool_false_node;
 
 case ADDR_EXPR:
   /* If we are taking the address of a decl that can never be null,
@@ -148,7 +148,7 @@ d_truthvalue_conversion (tree expr)
  warning (OPT_Waddress,
   "the address of %qD will always evaluate as %",
   TREE_OPERAND (expr, 0));
- return boolean_true_node;
+ return d_bool_true_node;
}
   break;
 
diff --git a/gcc/d/d-tree.h b/gcc/d/d-tree.h
index ed26533feb4..7763695a106 100644
--- a/gcc/d/d-tree.h
+++ b/gcc/d/d-tree.h
@@ -444,6 +444,9 @@ enum d_tree_index
   DTI_NULL_ARRAY,
   DTI_BOTTOM_TYPE,
 
+  DTI_BOOL_FALSE,
+  DTI_BOOL_TRUE,
+
   DTI_MAX
 };
 
@@ -480,6 +483,9 @@ extern GTY(()) tree d_global_trees[DTI_MAX];
 #define null_array_noded_global_trees[DTI_NULL_ARRAY]
 /* The bottom type, referred to as `noreturn` in code.  */
 #define noreturn_type_node d_global_trees[DTI_BOTTOM_TYPE]
+/* D boolean values are always byte-sized, unlike boolean_type_node.  */
+#define d_bool_false_node  d_global_trees[DTI_BOOL_FALSE]
+#define d_bool_true_node   d_global_trees[DTI_BOOL_TRUE]
 
 /* A prefix for internal variables, which are not user-visible.  */
 #if !defined (NO_DOT_IN_LABEL)
diff --git a/gcc/d/modules.cc b/gcc/d/modules.cc
index 8d6c8f0f9ad..e3c1ef9f82e 100644
--- a/gcc/d/modules.cc
+++ b/gcc/d/modules.cc
@@ -330

[committed] d: Merge upstream dmd, druntime e48bc0987d, phobos 2458e8f82.

2023-10-29 Thread Iain Buclaw
Hi,

This patch merges the D front-end and runtime library with upstream dmd
e48bc0987d, and standard library with phobos 2458e8f82.

Synchronizing with the v2.106.0-beta.1 release.

D front-end changes:

- Import dmd v2.106.0-beta.1.

D runtime changes:

- Import druntime v2.106.0-beta.1.

Phobos changes:

- Import phobos v2.106.0-beta.1.


Bootstrapped and regression tested on x86_64-linux-gnu/-m32, and
committed to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd e48bc0987d.
* expr.cc (ExprVisitor::visit (NewExp *)): Update for new front-end
interface.
* runtime.def (NEWARRAYT): Remove.
(NEWARRAYIT): Remove.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime e48bc0987d.
* src/MERGE: Merge upstream phobos 2458e8f82.
---
 gcc/d/dmd/MERGE   |   2 +-
 gcc/d/dmd/VERSION |   2 +-
 gcc/d/dmd/aggregate.d |   8 +-
 gcc/d/dmd/aggregate.h |   8 -
 gcc/d/dmd/aliasthis.h |   2 +-
 gcc/d/dmd/attrib.h|   1 -
 gcc/d/dmd/canthrow.d  |   2 +-
 gcc/d/dmd/cond.d  |   2 +-
 gcc/d/dmd/cond.h  |   2 -
 gcc/d/dmd/cparse.d|  17 +-
 gcc/d/dmd/dcast.d |   2 +-
 gcc/d/dmd/dclass.d|   8 +-
 gcc/d/dmd/declaration.d   |   1 +
 gcc/d/dmd/declaration.h   |  12 -
 gcc/d/dmd/denum.d |   2 +-
 gcc/d/dmd/dimport.d   |   2 +-
 gcc/d/dmd/dinterpret.d|   3 +
 gcc/d/dmd/dmodule.d   |   2 +-
 gcc/d/dmd/dscope.d|   2 +-
 gcc/d/dmd/dstruct.d   |   2 +-
 gcc/d/dmd/dsymbol.d   |   7 +-
 gcc/d/dmd/dsymbolsem.d|  15 +-
 gcc/d/dmd/dtemplate.d |   8 +-
 gcc/d/dmd/expression.d|  90 ++-
 gcc/d/dmd/expression.h|  88 +--
 gcc/d/dmd/expressionsem.d |  53 
 gcc/d/dmd/func.d  |  20 +-
 gcc/d/dmd/globals.h   |   6 +-
 gcc/d/dmd/hdrgen.d|  38 ++-
 gcc/d/dmd/id.d|   2 +
 gcc/d/dmd/import.h|   1 -
 gcc/d/dmd/init.h  |   1 -
 gcc/d/dmd/location.d  |   2 +-
 gcc/d/dmd/module.h|   1 -
 gcc/d/dmd/mtype.d |  16 +-
 gcc/d/dmd/mtype.h |  12 -
 gcc/d/dmd/objc.h  |   2 -
 gcc/d/dmd/scope.h |   2 -
 gcc/d/dmd/sideeffect.d|   4 +-
 gcc/d/dmd/statement.d |   6 +-
 gcc/d/dmd/statement.h |   4 +-
 gcc/d/dmd/template.h  |   5 -
 gcc/d/dmd/tokens.d|   2 +-
 gcc/d/dmd/tokens.h|   3 -
 gcc/d/expr.cc |  20 +-
 gcc/d/runtime.def |   9 +-
 .../gdc.test/fail_compilation/ice10727a.d |   2 +
 .../gdc.test/fail_compilation/ice10727b.d |   2 +
 libphobos/libdruntime/MERGE   |   2 +-
 .../core/internal/array/construction.d| 167 +
 .../libdruntime/core/internal/array/utils.d   | 236 ++
 libphobos/libdruntime/core/lifetime.d |  13 +-
 .../libdruntime/core/sys/freebsd/ifaddrs.d|  41 +++
 .../libdruntime/core/sys/freebsd/net/if_dl.d  |  42 
 .../libdruntime/core/sys/freebsd/sys/socket.d | 131 ++
 .../libdruntime/core/sys/freebsd/sys/types.d  |  58 +
 .../libdruntime/core/sys/posix/sys/types.d|   4 +-
 libphobos/libdruntime/object.d|   2 +
 libphobos/libdruntime/rt/lifetime.d   |  26 +-
 libphobos/src/MERGE   |   2 +-
 libphobos/src/std/parallelism.d   |   2 +-
 libphobos/src/std/range/primitives.d  |  10 +-
 libphobos/src/std/traits.d|  57 +
 63 files changed, 962 insertions(+), 334 deletions(-)
 create mode 100644 libphobos/libdruntime/core/sys/freebsd/ifaddrs.d
 create mode 100644 libphobos/libdruntime/core/sys/freebsd/net/if_dl.d
 create mode 100644 libphobos/libdruntime/core/sys/freebsd/sys/socket.d
 create mode 100644 libphobos/libdruntime/core/sys/freebsd/sys/types.d

diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index bfadeaa0c68..2a0baf09a4b 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-f4be7f6f7bae75f1613b862940cdd533b5ae99b2
+e48bc0987dfec35bc76a3015ee3e85906ce86dfd
 
 The first li

[committed] d: Fix ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr') [PR110712]

2023-10-29 Thread Iain Buclaw
Hi,

This patch fixes an ICE cause by the way the D front-end generates its
codegen around va_list types.

Static arrays in D are passed around by value, rather than decaying to a
pointer.  On x86_64 __builtin_va_list is an exception to this rule, but
semantically it's still treated as a static array.

This makes certain assignment operations fail due a mismatch in types.
As all examples in the test program are rejected by C/C++ front-ends,
these are now errors in D too to be consistent.

Bootstrapped and regression tested on x86-64-linux-gnu/-m32, committed
to mainline and backported to releases/gcc-12 and releases/gcc-13.

Regards,
Iain.

---
PR d/110712

gcc/d/ChangeLog:

* d-codegen.cc (d_build_call): Update call to convert_for_argument.
* d-convert.cc (is_valist_parameter_type): New function.
(check_valist_conversion): New function.
(convert_for_assignment): Update signature.  Add check whether
assigning va_list is permissible.
(convert_for_argument): Likewise.
* d-tree.h (convert_for_assignment): Update signature.
(convert_for_argument): Likewise.
* expr.cc (ExprVisitor::visit (AssignExp *)): Update call to
convert_for_assignment.

gcc/testsuite/ChangeLog:

* gdc.dg/pr110712.d: New test.
---
 gcc/d/d-codegen.cc  |   6 +-
 gcc/d/d-convert.cc  | 127 ++--
 gcc/d/d-tree.h  |   4 +-
 gcc/d/expr.cc   |  12 +--
 gcc/testsuite/gdc.dg/pr110712.d |  23 ++
 5 files changed, 139 insertions(+), 33 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/pr110712.d

diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 270cb5e2be6..5c53cf78577 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -2245,14 +2245,16 @@ d_build_call (TypeFunction *tf, tree callable, tree 
object,
   for (size_t i = 0; i < arguments->length; ++i)
{
  Expression *arg = (*arguments)[i];
- tree targ = build_expr (arg);
+ tree targ;
 
  if (i - varargs < nparams && i >= varargs)
{
  /* Actual arguments for declared formal arguments.  */
  Parameter *parg = tf->parameterList[i - varargs];
- targ = convert_for_argument (targ, parg);
+ targ = convert_for_argument (arg, parg);
}
+ else
+   targ = build_expr (arg);
 
  /* Don't pass empty aggregates by value.  */
  if (empty_aggregate_p (TREE_TYPE (targ)) && !TREE_ADDRESSABLE (targ)
diff --git a/gcc/d/d-convert.cc b/gcc/d/d-convert.cc
index 71d7a41374e..4c5375cba9a 100644
--- a/gcc/d/d-convert.cc
+++ b/gcc/d/d-convert.cc
@@ -694,16 +694,86 @@ convert_for_rvalue (tree expr, Type *etype, Type *totype)
   return result ? result : convert_expr (expr, etype, totype);
 }
 
+/* Helper for convert_for_assigment and convert_for_argument.
+   Returns true if EXPR is a va_list static array parameter.  */
+
+static bool
+is_valist_parameter_type (Expression *expr)
+{
+  Declaration *decl = NULL;
+
+  if (VarExp *ve = expr->isVarExp ())
+decl = ve->var;
+  else if (SymOffExp *se = expr->isSymOffExp ())
+decl = se->var;
+
+  if (decl != NULL && decl->isParameter () && valist_array_p (decl->type))
+return true;
+
+  return false;
+}
+
+/* Helper for convert_for_assigment and convert_for_argument.
+   Report erroneous uses of assigning or passing a va_list parameter.  */
+
+static void
+check_valist_conversion (Expression *expr, Type *totype, bool in_assignment)
+{
+  /* Parameter symbol and its converted type.  */
+  Declaration *decl = NULL;
+  /* Type of parameter when evaluated in the expression.  */
+  Type *type = NULL;
+
+  if (VarExp *ve = expr->isVarExp ())
+{
+  decl = ve->var;
+  type = ve->var->type->nextOf ()->pointerTo ();
+}
+  else if (SymOffExp *se = expr->isSymOffExp ())
+{
+  decl = se->var;
+  type = se->var->type->nextOf ()->pointerTo ()->pointerTo ();
+}
+
+  /* Should not be called unless is_valist_parameter_type also matched.  */
+  gcc_assert (decl != NULL && decl->isParameter ()
+ && valist_array_p (decl->type));
+
+  /* OK if conversion between types is allowed.  */
+  if (type->implicitConvTo (totype) != MATCH::nomatch)
+return;
+
+  if (in_assignment)
+{
+  error_at (make_location_t (expr->loc), "cannot convert parameter %qs "
+   "from type %qs to type %qs in assignment",
+   expr->toChars(), type->toChars (), totype->toChars ());
+}
+  else
+{
+  error_at (make_location_t (expr->loc), "cannot convert parameter %qs "
+   "from type %qs to type %qs in argument passing",
+   expr->toChars(), type->toChars (), totype->toChars ());
+}
+
+  inform (make_location_t (decl->loc), "parameters of type % "
+ "{aka %qs} are decayed to pointer types, and require % "
+ "to be converted back into a static array type

Re: [committed] d: Merge upstream dmd, druntime e48bc0987d, phobos 2458e8f82.

2023-10-30 Thread Iain Buclaw
Excerpts from Rainer Orth's message of Oktober 30, 2023 5:37 pm:
> Hi Iain,
> 
>> This patch merges the D front-end and runtime library with upstream dmd
>> e48bc0987d, and standard library with phobos 2458e8f82.
>>
>> Synchronizing with the v2.106.0-beta.1 release.
>>
>> D front-end changes:
>>
>> - Import dmd v2.106.0-beta.1.
> 
> this patch broke D bootstrap, it seems:
> 
> /vol/gcc/src/hg/master/local/gcc/d/expr.cc: In member function 'virtual void 
> ExprVisitor::visit(NewExp*)':
> /vol/gcc/src/hg/master/local/gcc/d/expr.cc:2361:21: error: unused variable 
> 'tarray' [-Werror=unused-variable]
>  2361 | TypeDArray *tarray = tb->isTypeDArray ();
>   | ^~
> 
> It removed the uses of tarray, but kept the initialization.
> 

Hi Rainer,

Thanks for spotting, I'll fix it up.

Iain.


[committed] d: Clean-up unused variable assignments after interface change

2023-10-31 Thread Iain Buclaw
Hi,

The lowering done for invoking `new' on a single dimension array was
moved from the code generator to the front-end semantic pass in 
r14-4996.  This removes the detritus left behind in the code generator
from that deletion.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* expr.cc (ExprVisitor::visit (NewExp *)): Remove unused assignments.
---
 gcc/d/expr.cc | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index ef4ea60ffed..17801a3bd1e 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -2357,9 +2357,6 @@ public:
 else if (tb->ty == TY::Tarray)
   {
/* Allocating memory for a new D array.  */
-   tb = e->newtype->toBasetype ();
-   TypeDArray *tarray = tb->isTypeDArray ();
-
gcc_assert (e->arguments && e->arguments->length >= 1);
 
if (e->arguments->length == 1)
@@ -2403,7 +2400,8 @@ public:
   size_int (e->arguments->length),
   build_address (var));
 
-   result = build_libcall (libcall, tb, 2, tinfo, dims);
+   result = build_libcall (libcall, e->newtype->toBasetype (), 2,
+   tinfo, dims);
  }
 
if (e->argprefix)
-- 
2.39.2



[committed] d: Merge upstream dmd, druntime 643b1261bb, phobos 1c98326e7

2023-11-02 Thread Iain Buclaw
Hi,

This patch merges the D front-end and runtime library with upstream dmd
643b1261bb, and standard library with phobos 1c98326e7.

Synchronizing with the v2.106.0-beta.1 release.

This is being done a little earlier than usual as there's a lot of
internal moving code around within upstream at the moment to reduce both
the extern(C++) surface area, and cyclic dependencies between all D
modules that implement the compiler. So it is done now to keep the diff
below the 400kb threshold enforced on the mailing list.

D front-end changes:

- Suggested preview switches now give gdc flags (PR109681).
- `new S[10]' is now lowered to `_d_newarrayT!S(10)'.

D runtime changes:

- Runtime compiler library functions `_d_newarrayU', `_d_newarrayT',
  `_d_newarrayiT' have been converted to templates.

Phobos changes:

- Add new `std.traits.Unshared' template.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 643b1261bb.
* d-attribs.cc (build_attributes): Update for new front-end interface.
* d-lang.cc (d_post_options): Likewise.
* decl.cc (layout_class_initializer): Likewise.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 643b1261bb.
* libdruntime/Makefile.am (DRUNTIME_DSOURCES_FREEBSD): Add
core/sys/freebsd/ifaddrs.d, core/sys/freebsd/net/if_dl.d,
core/sys/freebsd/sys/socket.d, core/sys/freebsd/sys/types.d.
(DRUNTIME_DSOURCES_LINUX): Add core/sys/linux/linux/if_arp.d,
core/sys/linux/linux/if_packet.d.
* libdruntime/Makefile.in: Regenerate.
* src/MERGE: Merge upstream phobos 1c98326e7.
---
 gcc/d/d-attribs.cc|   2 +-
 gcc/d/d-lang.cc   |   1 -
 gcc/d/decl.cc |   2 +-
 gcc/d/dmd/MERGE   |   2 +-
 gcc/d/dmd/aggregate.d | 184 +++---
 gcc/d/dmd/attrib.d|   6 +-
 gcc/d/dmd/cond.d  |   1 +
 gcc/d/dmd/constfold.d |  24 +-
 gcc/d/dmd/cparse.d|   1 +
 gcc/d/dmd/dcast.d |   3 +-
 gcc/d/dmd/dclass.d|   2 +-
 gcc/d/dmd/declaration.d   |  50 +-
 gcc/d/dmd/dinterpret.d|   3 +-
 gcc/d/dmd/dmangle.d   |   1 +
 gcc/d/dmd/doc.d   |   2 +-
 gcc/d/dmd/dstruct.d   |   2 +-
 gcc/d/dmd/dsymbol.d   |  74 ++-
 gcc/d/dmd/dsymbolsem.d|  11 +-
 gcc/d/dmd/dtemplate.d |  15 +-
 gcc/d/dmd/expression.d| 546 +-
 gcc/d/dmd/expression.h|  20 +-
 gcc/d/dmd/expressionsem.d | 511 +++-
 gcc/d/dmd/func.d  |   1 +
 gcc/d/dmd/globals.h   |   1 -
 gcc/d/dmd/gluelayer.d |   5 -
 gcc/d/dmd/initsem.d   |   1 +
 gcc/d/dmd/lexer.d |   1 -
 gcc/d/dmd/mtype.d |  25 +-
 gcc/d/dmd/mtype.h |   2 +-
 gcc/d/dmd/optimize.d  |   1 +
 gcc/d/dmd/parse.d |  22 +-
 gcc/d/dmd/semantic3.d |   7 +-
 gcc/d/dmd/statementsem.d  |   5 +-
 gcc/d/dmd/staticcond.d|   1 +
 gcc/d/dmd/templateparamsem.d  |   1 +
 gcc/d/dmd/traits.d|   1 +
 gcc/d/dmd/typesem.d   |   2 +
 gcc/d/dmd/typinf.d|  30 +-
 gcc/d/dmd/typinf.h|  22 +
 gcc/testsuite/gdc.test/compilable/dbitfield.d |  13 +
 .../gdc.test/compilable/deprecate14283.d  |   8 +-
 .../gdc.test/compilable/named_arguments.d |  18 +-
 gcc/testsuite/gdc.test/compilable/test20039.d |   2 +-
 .../gdc.test/fail_compilation/b23686.d|  42 ++
 .../gdc.test/fail_compilation/diag4596.d  |   4 +-
 .../gdc.test/fail_compilation/fail13116.d |   2 +-
 .../gdc.test/fail_compilation/fail24208.d |  20 +
 .../gdc.test/fail_compilation/fail24212.d |  30 +
 .../gdc.test/fail_compilation/fail24213.d |  17 +
 .../gdc.test/fail_compilation/ice23865.d  |  32 +
 .../gdc.test/fail_compilation/ice24188.d  |  14 +
 .../fail_compilation/ice24188_a/ice24188_c.d  |   0
 .../gdc.test/fail_compilation/test18480.d |   1 +
 .../gdc.test/fail_compilation/test24157.d |  28 +
 libphobos/libdruntime/MERGE   |   2 +-
 libphobos/libdruntime/Makefile.am |   7 +-
 libphobos/libdruntime/Makefile.in |  34 +-
 .../libdruntime/core/sys/linux/linux/if_arp.d | 136 +

[committed][GCC13] d: Fix internal compiler error: in make_import, at d/imports.cc:48 [PR113125]

2024-03-02 Thread Iain Buclaw
Hi,

This patch backports an ICE triggered in the D front-end.

The cause of the ICE was that TYPE_DECLs were only being generated for
structs with members, not opaque structs.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, backported
to releases/gcc-13, releases/gcc-12, and releases/gcc-11.

Regards,
Iain.

---
PR d/113125

gcc/d/ChangeLog:

* types.cc (TypeVisitor::visit (TypeStruct *)): Generate TYPE_DECL and
apply UDAs to opaque struct declarations.

gcc/testsuite/ChangeLog:

* gdc.dg/imports/pr113125.d: New test.
* gdc.dg/pr113125.d: New test.

(cherry picked from commit b0efb1c35724e3332ee5993976efb98200c1a154)
---
 gcc/d/types.cc  | 5 +
 gcc/testsuite/gdc.dg/imports/pr113125.d | 2 ++
 gcc/testsuite/gdc.dg/pr113125.d | 4 
 3 files changed, 11 insertions(+)
 create mode 100644 gcc/testsuite/gdc.dg/imports/pr113125.d
 create mode 100644 gcc/testsuite/gdc.dg/pr113125.d

diff --git a/gcc/d/types.cc b/gcc/d/types.cc
index f19779fec7d..05050f9edd0 100644
--- a/gcc/d/types.cc
+++ b/gcc/d/types.cc
@@ -1230,6 +1230,11 @@ public:
apply_user_attributes (t->sym, t->ctype);
finish_aggregate_type (structsize, alignsize, t->ctype);
   }
+else
+  {
+   build_type_decl (t->ctype, t->sym);
+   apply_user_attributes (t->sym, t->ctype);
+  }
 
 /* For structs with a user defined postblit, copy constructor, or a
destructor, also set TREE_ADDRESSABLE on the type and all variants.
diff --git a/gcc/testsuite/gdc.dg/imports/pr113125.d 
b/gcc/testsuite/gdc.dg/imports/pr113125.d
new file mode 100644
index 000..761e613b055
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/imports/pr113125.d
@@ -0,0 +1,2 @@
+module imports.pr113125;
+struct S113125;
diff --git a/gcc/testsuite/gdc.dg/pr113125.d b/gcc/testsuite/gdc.dg/pr113125.d
new file mode 100644
index 000..cb7300baa1a
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr113125.d
@@ -0,0 +1,4 @@
+// { dg-do compile }
+// { dg-options "-I $srcdir/gdc.dg" }
+module pr113125;
+import imports.pr113125: S113125;
-- 
2.40.1



[committed][GCC13] d: Fix callee destructor call invalidates the live object [PR113758]

2024-03-02 Thread Iain Buclaw
Hi,

This patch backports a fix to code generation when passing objects by
invisible reference that have a defined cpctor or dtor.

When generating the argument, check the isCalleeDestroyingArgs hook, and
force a TARGET_EXPR to be created if true, so that a reference to the
live object isn't passed directly to the function that runs dtors.

When instead dealing with caller running destructors, two temporaries
were being generated, one explicit temporary generated by the D
front-end, and another implicitly by the code generator.  This has been
reduced to one by setting DECL_VALUE_EXPR on the explicit temporary to
bind it to the implicit slot created for the TARGET_EXPR, as that has
the shorter lifetime of the two.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, backported
to releases/gcc-13, releases/gcc-12, and releases/gcc-11.

Regards,
Iain.

---
PR d/113758

gcc/d/ChangeLog:

* d-codegen.cc (d_build_call): Force a TARGET_EXPR when callee
destorys its arguments.
* decl.cc (DeclVisitor::visit (VarDeclaration *)): Set
SET_DECL_VALUE_EXPR on the temporary variable to make it a placeholder
for the TARGET_EXPR_SLOT.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/pr113758.d: New test.

(cherry picked from commit 3c57b1c12a8e34d50bdf6aaf44146760db6d1b33)
---
 gcc/d/d-codegen.cc  | 15 +++
 gcc/d/decl.cc   | 22 --
 gcc/testsuite/gdc.dg/torture/pr113758.d | 19 +++
 3 files changed, 50 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/torture/pr113758.d

diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 8fe659ad527..b8e4b83d2de 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -2213,10 +2213,17 @@ d_build_call (TypeFunction *tf, tree callable, tree 
object,
  Type *t = arg->type->toBasetype ();
  StructDeclaration *sd = t->baseElemOf ()->isTypeStruct ()->sym;
 
- /* Nested structs also have ADDRESSABLE set, but if the type has
-neither a copy constructor nor a destructor available, then we
-need to take care of copying its value before passing it.  */
- if (arg->op == EXP::structLiteral || (!sd->postblit && !sd->dtor))
+ /* Need to take care of copying its value before passing the
+argument in the following scenarios:
+- The argument is a literal expression; a CONSTRUCTOR can't
+have its address taken.
+- The type has neither a copy constructor nor a destructor
+available; nested structs also have ADDRESSABLE set.
+- The ABI of the function expects the callee to destroy its
+arguments; when the caller is handles destruction, then `targ'
+has already been made into a temporary. */
+ if (arg->op == EXP::structLiteral || (!sd->postblit && !sd->dtor)
+ || target.isCalleeDestroyingArgs (tf))
targ = force_target_expr (targ);
 
  targ = convert (build_reference_type (TREE_TYPE (targ)),
diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 0375ede082b..2a135b516aa 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -860,10 +860,28 @@ public:
/* Maybe put variable on list of things needing destruction.  */
if (d->needsScopeDtor ())
  {
+   /* Rewrite: `decl = exp' => TARGET_EXPR(decl, exp, dtor).  */
vec_safe_push (d_function_chain->vars_in_scope, decl);
+
/* Force a TARGET_EXPR to add the corresponding cleanup.  */
-   exp = force_target_expr (compound_expr (exp, decl));
-   TARGET_EXPR_CLEANUP (exp) = build_expr (d->edtor);
+   if (TREE_CODE (exp) != TARGET_EXPR)
+ {
+   if (VOID_TYPE_P (TREE_TYPE (exp)))
+ exp = compound_expr (exp, decl);
+
+   exp = force_target_expr (exp);
+ }
+
+   TARGET_EXPR_CLEANUP (exp)
+ = compound_expr (TARGET_EXPR_CLEANUP (exp),
+  build_expr (d->edtor));
+
+   /* The decl is really an alias for the TARGET_EXPR slot.  */
+   SET_DECL_VALUE_EXPR (decl, TARGET_EXPR_SLOT (exp));
+   DECL_HAS_VALUE_EXPR_P (decl) = 1;
+   /* This tells the gimplifier not to emit a clobber for the decl
+  as its lifetime ends when the slot gets cleaned up.  */
+   TREE_ADDRESSABLE (decl) = 0;
  }
 
add_stmt (exp);
diff --git a/gcc/testsuite/gdc.dg/torture/pr113758.d 
b/gcc/testsuite/gdc.dg/torture/pr113758.d
new file mode 100644
index 000..dc53883a8de
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/torture/pr113758.d
@@ -0,0 +1,19 @@
+// { dg-do run }
+// { dg-skip-if "needs gcc/config.d" { ! d_runtime }

[committed] d: Fix gdc -O2 -mavx generates misaligned vmovdqa instruction [PR114171]

2024-03-02 Thread Iain Buclaw
Hi,

This patch fixes a wrong code issue in the D front-end where lowered
struct comparisons would reinterpret fields with a different (usually
bigger) alignment than the original.  Use `build_aligned_type' to
preserve the alignment when casting away for such comparisons.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline, and backported to releases/gcc-13, releases/gcc-12, and
releases/gcc-11.

Regards,
Iain.
---
PR d/114171

gcc/d/ChangeLog:

* d-codegen.cc (lower_struct_comparison): Keep alignment of original
type in reinterpret cast for comparison.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/pr114171.d: New test.
---
 gcc/d/d-codegen.cc  |  1 +
 gcc/testsuite/gdc.dg/torture/pr114171.d | 29 +
 2 files changed, 30 insertions(+)
 create mode 100644 gcc/testsuite/gdc.dg/torture/pr114171.d

diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 5bc233928aa..43d7739f8fc 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -1006,6 +1006,7 @@ lower_struct_comparison (tree_code code, 
StructDeclaration *sd,
  if (tmode == NULL_TREE)
tmode = make_unsigned_type (GET_MODE_BITSIZE (mode.require ()));
 
+ tmode = build_aligned_type (tmode, TYPE_ALIGN (stype));
  t1ref = build_vconvert (tmode, t1ref);
  t2ref = build_vconvert (tmode, t2ref);
 
diff --git a/gcc/testsuite/gdc.dg/torture/pr114171.d 
b/gcc/testsuite/gdc.dg/torture/pr114171.d
new file mode 100644
index 000..0f9ffcab916
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/torture/pr114171.d
@@ -0,0 +1,29 @@
+// { dg-do run }
+// { dg-additional-options "-mavx" { target avx_runtime } }
+// { dg-skip-if "needs gcc/config.d" { ! d_runtime } }
+import gcc.builtins;
+
+struct S1
+{
+string label;
+}
+
+struct S2
+{
+ulong pad;
+S1 label;
+}
+
+pragma(inline, false)
+auto newitem()
+{
+void *p = __builtin_malloc(S2.sizeof);
+__builtin_memset(p, 0, S2.sizeof);
+return cast(S2*) p;
+}
+
+int main()
+{
+auto bn = newitem();
+return bn.label is S1.init ? 0 : 1;
+}
-- 
2.40.1



Re: [committed] d: Fix gdc -O2 -mavx generates misaligned vmovdqa instruction [PR114171]

2024-03-03 Thread Iain Buclaw
Excerpts from Richard Biener's message of März 3, 2024 11:41 am:
> 
> 
>> Am 03.03.2024 um 02:51 schrieb Iain Buclaw :
>> 
>> Hi,
>> 
>> This patch fixes a wrong code issue in the D front-end where lowered
>> struct comparisons would reinterpret fields with a different (usually
>> bigger) alignment than the original.  Use `build_aligned_type' to
>> preserve the alignment when casting away for such comparisons.
>> 
>> Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
>> to mainline, and backported to releases/gcc-13, releases/gcc-12, and
>> releases/gcc-11.
> 
> LGTM.  You might want to experiment with not doing the premature optimization 
> but instead use __builtin_memcmp_eq (assuming that’s a general good fit).  
> The middle-end should better turn that into target optimal code.
> 

Indeed, just looking at the history, it was introduced well over ten
years ago so I can't comment on the original context for it (it doesn't
directly fix any old issues).

Small comparison between this optimization and memcmp_eq
---
  _5 = newitem ();
  # DEBUG bn => _5
  _1 = MEM[(ucent *)_5 + 8B];
  _2 = _1 != 0;
  _6 = (int) _2;
  return _6;
---
call_D8pr1141717newitemFNbNiZPSQz2S2
.LVL29:
vmovdqu 8(%rax), %xmm0
xorl%eax, %eax
.LVL30:
vptest  %xmm0, %xmm0
setne   %al
addq$8, %rsp
ret


---
  _6 = newitem ();
  # DEBUG bn => _6
  D.2335.length = 0;
  D.2335.ptr = 0B;
  _1 = &_6->label.label;
  _2 = __builtin_memcmp_eq (_1, &D.2335, 16);
  _3 = _2 != 0;
  _9 = (int) _3;
  return _9;
---
call_D8pr1141717newitemFNbNiZPSQz2S2
.LVL29:
movq$0, (%rsp)
movq$0, 8(%rsp)
vmovdqu 8(%rax), %xmm0
xorl%eax, %eax
.LVL30:
vpxor   (%rsp), %xmm0, %xmm0
vptest  %xmm0, %xmm0
setne   %al
addq$24, %rsp
ret


[committed] d: Merge upstream dmd, druntime f8bae04558, phobos ba2ade9dec

2024-03-03 Thread Iain Buclaw
Hi,

This patch merges the D front-end and runtime library with upstream dmd
f8bae04558, and the standard library with phobos ba2ade9dec

D front-end changes:

- Import dmd v2.108.1-beta-1.

D runtime changes:

- Import druntime v2.108.1-beta-1.

Phobos changes:

- Import phobos v2.108.1-beta-1.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd f8bae04558.
* dmd/VERSION: Bump version to v2.108.0-beta.1.
* d-builtins.cc (build_frontend_type): Update for new front-end
interface.
* d-codegen.cc (build_assert_call): Likewise.
* d-convert.cc (d_array_convert): Likewise.
* decl.cc (get_vtable_decl): Likewise.
* expr.cc (ExprVisitor::visit (EqualExp *)): Likewise.
(ExprVisitor::visit (VarExp *)): Likewise.
(ExprVisitor::visit (ArrayLiteralExp *)): Likewise.
(ExprVisitor::visit (AssocArrayLiteralExp)): Likewise.
* intrinsics.cc (build_shuffle_mask_type): Likewise.
(maybe_warn_intrinsic_mismatch): Likewise.
* runtime.cc (get_libcall_type): Likewise.
* typeinfo.cc (TypeInfoVisitor::layout_string): Likewise.
(TypeInfoVisitor::visit(TypeInfoTupleDeclaration *)): Likewise.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 02d6d07a69.
* src/MERGE: Merge upstream phobos a2ade9dec.
---
 gcc/d/d-builtins.cc   |   6 +-
 gcc/d/d-codegen.cc|   2 +-
 gcc/d/d-convert.cc|   4 +-
 gcc/d/decl.cc |   2 +-
 gcc/d/dmd/MERGE   |   2 +-
 gcc/d/dmd/VERSION |   2 +-
 gcc/d/dmd/constfold.d |   2 +-
 gcc/d/dmd/cparse.d|   8 +-
 gcc/d/dmd/cxxfrontend.d   |  36 ++
 gcc/d/dmd/denum.d |   1 -
 gcc/d/dmd/dinterpret.d|   4 +-
 gcc/d/dmd/dmodule.d   |  16 +-
 gcc/d/dmd/expressionsem.d |  14 +-
 gcc/d/dmd/func.d  | 176 --
 gcc/d/dmd/funcsem.d   | 168 +
 gcc/d/dmd/location.d  |  10 +-
 gcc/d/dmd/mtype.d | 321 +-
 gcc/d/dmd/mtype.h |  14 +-
 gcc/d/dmd/optimize.d  |   2 +-
 gcc/d/dmd/safe.d  |   2 +-
 gcc/d/dmd/typesem.d   | 317 -
 gcc/d/expr.cc |  21 +-
 gcc/d/intrinsics.cc   |   6 +-
 gcc/d/runtime.cc  |  20 +-
 gcc/d/typeinfo.cc |   4 +-
 .../gdc.test/compilable/issue24399.d  |   9 +
 .../gdc.test/compilable/issue24409.d  |  17 +
 gcc/testsuite/gdc.test/runnable/issue24401.d  |   6 +
 gcc/testsuite/gdc.test/runnable/test24371.d   |  15 +
 .../gdc.test/runnable_cxx/test7925.d  |   7 -
 libphobos/libdruntime/MERGE   |   2 +-
 libphobos/libdruntime/core/exception.d|  13 +
 .../libdruntime/core/sys/linux/ifaddrs.d  |  11 +-
 .../libdruntime/core/sys/posix/sys/select.d   |  44 +--
 libphobos/src/MERGE   |   2 +-
 libphobos/src/etc/c/zlib.d|  49 +--
 36 files changed, 717 insertions(+), 618 deletions(-)
 create mode 100644 gcc/testsuite/gdc.test/compilable/issue24399.d
 create mode 100644 gcc/testsuite/gdc.test/compilable/issue24409.d
 create mode 100644 gcc/testsuite/gdc.test/runnable/issue24401.d
 create mode 100644 gcc/testsuite/gdc.test/runnable/test24371.d

diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc
index dc50df4252c..4546c0e9b56 100644
--- a/gcc/d/d-builtins.cc
+++ b/gcc/d/d-builtins.cc
@@ -197,8 +197,8 @@ build_frontend_type (tree type)
  length = size_binop (PLUS_EXPR, size_one_node,
   convert (sizetype, length));
 
- dtype =
-   dmd::addMod (dtype->sarrayOf (TREE_INT_CST_LOW (length)), mod);
+ dtype = dmd::sarrayOf (dtype, TREE_INT_CST_LOW (length));
+ dtype = dmd::addMod (dtype, mod);
  builtin_converted_decls.safe_push (builtin_data (dtype, type));
  return dtype;
}
@@ -214,7 +214,7 @@ build_frontend_type (tree type)
   if (!dtype)
break;
 
-  dtype = dmd::addMod (dtype->sarrayOf (nunits), mod);
+  dtype = dmd::addMod (dmd::sarrayOf (dtype, nunits), mod);
   if (target.isVectorTypeSupported (dtype->size (), dtype->nextOf ()))
break;
 
diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 43d7739f8fc..2b3089b5f6d 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -1906,7 +1906,7 @@ build_assert_call (const Loc &loc, libcall_fn libcall, 

Re: [committed] d: Fix gdc -O2 -mavx generates misaligned vmovdqa instruction [PR114171]

2024-03-03 Thread Iain Buclaw
Excerpts from Andrew Pinski's message of März 3, 2024 11:49 pm:
> On Sat, Mar 2, 2024 at 5:51 PM Iain Buclaw  wrote:
>>
>> Hi,
>>
>> This patch fixes a wrong code issue in the D front-end where lowered
>> struct comparisons would reinterpret fields with a different (usually
>> bigger) alignment than the original.  Use `build_aligned_type' to
>> preserve the alignment when casting away for such comparisons.
>>
>> Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
>> to mainline, and backported to releases/gcc-13, releases/gcc-12, and
>> releases/gcc-11.
>>
>> Regards,
>> Iain.
>> ---
>> PR d/114171
>>
>> gcc/d/ChangeLog:
>>
>> * d-codegen.cc (lower_struct_comparison): Keep alignment of original
>> type in reinterpret cast for comparison.
>>
>> gcc/testsuite/ChangeLog:
>>
>> * gdc.dg/torture/pr114171.d: New test.
>> ---
>>  gcc/d/d-codegen.cc  |  1 +
>>  gcc/testsuite/gdc.dg/torture/pr114171.d | 29 +
>>  2 files changed, 30 insertions(+)
>>  create mode 100644 gcc/testsuite/gdc.dg/torture/pr114171.d
>>
>> diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
>> index 5bc233928aa..43d7739f8fc 100644
>> --- a/gcc/d/d-codegen.cc
>> +++ b/gcc/d/d-codegen.cc
>> @@ -1006,6 +1006,7 @@ lower_struct_comparison (tree_code code, 
>> StructDeclaration *sd,
>>   if (tmode == NULL_TREE)
>> tmode = make_unsigned_type (GET_MODE_BITSIZE (mode.require 
>> ()));
>>
>> + tmode = build_aligned_type (tmode, TYPE_ALIGN (stype));
> 
> You might also need to build a may_alias variant too. Or make sure the
> access is using the correct aliasing set.
> I have not checked if the D front-end does anything special for
> aliasing sets so I am not sure if that is needed or not but I suspect
> it is.
> 

There are no alias sets defined in the D front-end - the reference
compiler doesn't enforce it, which has allowed enough code out there
to expect modifying bits (eg: of a float) through a reinterpret cast
(such as an int*) to just work.

Thanks for the reminder though.
Iain.


Re: Frontend access to target features (was Re: [PATCH] libgccjit: Add ability to get CPU features)

2024-03-10 Thread Iain Buclaw
Excerpts from David Malcolm's message of März 5, 2024 4:09 pm:
> On Thu, 2023-11-09 at 19:33 -0500, Antoni Boucher wrote:
>> Hi.
>> See answers below.
>> 
>> On Thu, 2023-11-09 at 18:04 -0500, David Malcolm wrote:
>> > On Thu, 2023-11-09 at 17:27 -0500, Antoni Boucher wrote:
>> > > Hi.
>> > > This patch adds support for getting the CPU features in libgccjit
>> > > (bug
>> > > 112466)
>> > > 
>> > > There's a TODO in the test:
>> > > I'm not sure how to test that gcc_jit_target_info_arch returns
>> > > the
>> > > correct value since it is dependant on the CPU.
>> > > Any idea on how to improve this?
>> > > 
>> > > Also, I created a CStringHash to be able to have a
>> > > std::unordered_set. Is there any built-in way of
>> > > doing
>> > > this?
>> > 
>> > Thanks for the patch.
>> > 
>> > Some high-level questions:
>> > 
>> > Is this specifically about detecting capabilities of the host that
>> > libgccjit is currently running on? or how the target was configured
>> > when libgccjit was built?
>> 
>> I'm less sure about this part. I'll need to do more tests.
>> 
>> > 
>> > One of the benefits of libgccjit is that, in theory, we support all
>> > of
>> > the targets that GCC already supports.  Does this patch change
>> > that,
>> > or
>> > is this more about giving client code the ability to determine
>> > capabilities of the specific host being compiled for?
>> 
>> This should not change that. If it does, this is a bug.
>> 
>> > 
>> > I'm nervous about having per-target jit code.  Presumably there's a
>> > reason that we can't reuse existing target logic here - can you
>> > please
>> > describe what the problem is.  I see that the ChangeLog has:
>> > 
>> > > * config/i386/i386-jit.cc: New file.
>> > 
>> > where i386-jit.cc has almost 200 lines of nontrivial code.  Where
>> > did
>> > this come from?  Did you base it on existing code in our source
>> > tree,
>> > making modifications to fit the new internal API, or did you write
>> > it
>> > from scratch?  In either case, how onerous would this be for other
>> > targets?
>> 
>> This was mostly copied from the same code done for the Rust and D
>> frontends.
>> See this commit and the following:
>> https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=b1c06fd9723453dd2b2ec306684cb806dc2b4fbb
>> The equivalent to i386-jit.cc is there:
>> https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=22e3557e2d52f129f2bbfdc98688b945dba28dc9
> 
> [CCing Iain and Arthur re those patches; for reference, the patch being
> discussed is attached to :
> https://gcc.gnu.org/pipermail/jit/2024q1/001792.html ]
> 
> One of my concerns about this patch is that we seem to be gaining code
> that's per-(frontend x config) which seems to be copied and pasted with
> a search and replace, which could lead to an M*N explosion.
> 

That's certainly the case with the configure/make rules. Itself I think
is copied originally from the {cpu_type}-protos.h machinery.

It might be worth pointing out that the c-family of front-ends don't
have separate headers because their per-target macros are defined in
{cpu_type}.h directly - for better or worse.

> Is there any real difference between the per-config code for the
> different frontends, or should there be a general "enumerate all
> features of the target" hook that's independent of the frontend? (but
> perhaps calls into it).
> 

As far as I understand, the configure parts should all be identical
between tm_p, tm_d, tm_rust, ..., so would benefit from being templated
to aid any other front-ends adding in their own per target hooks.

> Am I right in thinking that (rustc with default LLVM backend) has some
> set of feature strings that both (rustc with rustc_codegen_gcc) and
> gccrs are trying to emulate?  If so, is it presumably a goal that
> libgccjit gives identical results to gccrs?  If so, would it be crazy
> for libgccjit to consume e.g. config/i386/i386-rust.cc ?

I don't know whether libgccjit can just pull in directly the
implementation of the rust target hooks here.  The per-frontend target
hooks usually also make use of code specific to that front-end -
TARGET_CPU_CPP_BUILTINS and others can't be used by a non-c-family
front-end without adding a plethora of stubs, for example.

Whether or not libgccjit wants to give identical information as as rust
I think is a decision for you as the maintainer of its API.

Iain.


[committed] d: Fix -fpreview=in ICEs with forward referenced parameter [PR112285]

2024-03-10 Thread Iain Buclaw
Hi,

This patch removes the early lowering of D AST types as GCC trees in
Target::preferPassByRef, fixing both PR12285 and PR12290.

The way that the target hook preferPassByRef is implemented, it relied
on the GCC "back-end" tree type to determine whether or not to use `ref'
ABI for D `in' parameters; e.g: prefer by value if it is expected that
the target will pass the type around in registers.

Building the GCC tree type depends on the AST type being complete - all
semantic processing is finished - but as this hook is called from the
front-end, this will not be the case for forward referenced or
self-referencing types.

The consensus in upstream is that `in' parameters should always be
implicitly `ref', but as the front-end does not yet support all types
being rvalue references, limit this just static arrays and structs.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline and backported to releases/gcc-13 and releases/gcc-12.

Regards,
Iain.

---
PR d/112285
PR d/112290

gcc/d/ChangeLog:

* d-target.cc (Target::preferPassByRef): Return true for all static
array and struct types.

gcc/testsuite/ChangeLog:

* gdc.dg/pr112285.d: New test.
* gdc.dg/pr112290.d: New test.
---
 gcc/d/d-target.cc   | 25 +
 gcc/testsuite/gdc.dg/pr112285.d | 13 +
 gcc/testsuite/gdc.dg/pr112290.d | 15 +++
 3 files changed, 33 insertions(+), 20 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/pr112285.d
 create mode 100644 gcc/testsuite/gdc.dg/pr112290.d

diff --git a/gcc/d/d-target.cc b/gcc/d/d-target.cc
index b9d124422b7..9b69b0bc873 100644
--- a/gcc/d/d-target.cc
+++ b/gcc/d/d-target.cc
@@ -575,31 +575,16 @@ Target::supportsLinkerDirective (void) const
 }
 
 /* Decides whether an `in' parameter of the specified POD type PARAM_TYPE is to
-   be passed by reference or by valie.  This is used only when compiling with
+   be passed by reference or by value.  This is used only when compiling with
`-fpreview=in' enabled.  */
 
 bool
 Target::preferPassByRef (Type *param_type)
 {
-  if (param_type->size () == SIZE_INVALID)
+  /* See note in Target::isReturnOnStack.  */
+  Type *tb = param_type->toBasetype ();
+  if (tb->size () == SIZE_INVALID)
 return false;
 
-  tree type = build_ctype (param_type);
-
-  /* Prefer a `ref' if the type is an aggregate, and its size is greater than
- its alignment.  */
-  if (AGGREGATE_TYPE_P (type)
-  && (!valid_constant_size_p (TYPE_SIZE_UNIT (type))
- || compare_tree_int (TYPE_SIZE_UNIT (type), TYPE_ALIGN (type)) > 0))
-return true;
-
-  /* If the back-end is always going to pass this by invisible reference.  */
-  if (pass_by_reference (NULL, function_arg_info (type, true)))
-return true;
-
-  /* If returning the parameter means the caller will do RVO.  */
-  if (targetm.calls.return_in_memory (type, NULL_TREE))
-return true;
-
-  return false;
+  return (tb->ty == TY::Tstruct || tb->ty == TY::Tsarray);
 }
diff --git a/gcc/testsuite/gdc.dg/pr112285.d b/gcc/testsuite/gdc.dg/pr112285.d
new file mode 100644
index 000..5ca100a74a9
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr112285.d
@@ -0,0 +1,13 @@
+// { dg-do compile }
+// { dg-additional-options "-fpreview=in" }
+struct S112285
+{
+}
+
+class C112285
+{
+S112285 s;
+void f112285(in C112285)
+{
+}
+}
diff --git a/gcc/testsuite/gdc.dg/pr112290.d b/gcc/testsuite/gdc.dg/pr112290.d
new file mode 100644
index 000..7456fc21be1
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr112290.d
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-additional-options "-fpreview=in" }
+struct S112290a
+{
+S112290b* p;
+bool opEquals(in S112290a)
+{
+return p == p;
+}
+}
+
+struct S112290b
+{
+string s;
+}
-- 
2.40.1



[committed] d: Merge upstream dmd, druntime 855353a1d9

2024-03-17 Thread Iain Buclaw
Hi,

This patch merges the D front-end and runtime library with upstream dmd
855353a1d9.

D front-end changes:

- Import dmd v2.108.0-rc.1.
- Add support for Named Arguments for functions.
- Hex strings now convert to integer arrays.

D runtime changes:

- Import druntime v2.108.0-rc.1.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 855353a1d9.
* dmd/VERSION:

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 855353a1d9.
---
 gcc/d/dmd/MERGE   |  2 +-
 gcc/d/dmd/VERSION |  2 +-
 gcc/d/dmd/cxxfrontend.d   | 10 +++
 gcc/d/dmd/dcast.d | 31 ---
 gcc/d/dmd/dinterpret.d|  2 +-
 gcc/d/dmd/dsymbolsem.d|  7 +-
 gcc/d/dmd/dtemplate.d | 48 +--
 gcc/d/dmd/enum.h  |  6 ++
 gcc/d/dmd/expression.h| 15 
 gcc/d/dmd/expressionsem.d |  9 +-
 gcc/d/dmd/hdrgen.d|  3 +-
 gcc/d/dmd/lexer.d |  1 -
 gcc/d/dmd/mtype.d | 17 ++--
 gcc/d/dmd/mtype.h |  5 +-
 gcc/d/dmd/root/filename.d |  2 +-
 gcc/d/dmd/root/filename.h |  2 +-
 gcc/d/dmd/template.h  | 16 +---
 gcc/d/dmd/templatesem.d   | 85 ---
 gcc/d/dmd/typesem.d   | 16 +++-
 .../compilable/named_arguments_auto_ref.d | 39 +
 .../compilable/named_arguments_ifti.d | 27 ++
 .../gdc.test/fail_compilation/hexstring.d |  5 +-
 .../fail_compilation/named_arguments_error.d  | 11 ++-
 .../named_arguments_ifti_error.d  | 20 +
 gcc/testsuite/gdc.test/runnable/literal.d | 10 ++-
 libphobos/libdruntime/MERGE   |  2 +-
 .../core/internal/gc/impl/conservative/gc.d   |  4 +-
 .../core/internal/gc/impl/manual/gc.d |  2 +-
 .../core/internal/gc/impl/proto/gc.d  |  2 +-
 29 files changed, 294 insertions(+), 107 deletions(-)
 create mode 100644 gcc/testsuite/gdc.test/compilable/named_arguments_auto_ref.d
 create mode 100644 gcc/testsuite/gdc.test/compilable/named_arguments_ifti.d
 create mode 100644 
gcc/testsuite/gdc.test/fail_compilation/named_arguments_ifti_error.d

diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 4c0a0bc2aac..a00872ef864 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-f8bae0455851a1dfc8113d69323415f6de549e39
+855353a1d9e16d43e85b6cf2b03aef388619bd16
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/VERSION b/gcc/d/dmd/VERSION
index 416807683f5..8ca452f8912 100644
--- a/gcc/d/dmd/VERSION
+++ b/gcc/d/dmd/VERSION
@@ -1 +1 @@
-v2.108.0-beta.1
+v2.108.0-rc.1
diff --git a/gcc/d/dmd/cxxfrontend.d b/gcc/d/dmd/cxxfrontend.d
index 8c046343468..a0432d2e1b4 100644
--- a/gcc/d/dmd/cxxfrontend.d
+++ b/gcc/d/dmd/cxxfrontend.d
@@ -14,6 +14,7 @@ import dmd.aggregate : AggregateDeclaration;
 import dmd.arraytypes;
 import dmd.astenums;
 import dmd.common.outbuffer : OutBuffer;
+import dmd.denum : EnumDeclaration;
 import dmd.dmodule /*: Module*/;
 import dmd.dscope : Scope;
 import dmd.dstruct /*: StructDeclaration*/;
@@ -213,6 +214,15 @@ void genCppHdrFiles(ref Modules ms)
 return dmd.dtoh.genCppHdrFiles(ms);
 }
 
+/***
+ * enumsem.d
+ */
+Expression getDefaultValue(EnumDeclaration ed, const ref Loc loc)
+{
+import dmd.enumsem;
+return dmd.enumsem.getDefaultValue(ed, loc);
+}
+
 /***
  * expression.d
  */
diff --git a/gcc/d/dmd/dcast.d b/gcc/d/dmd/dcast.d
index a49bd575f4b..8a713f424d6 100644
--- a/gcc/d/dmd/dcast.d
+++ b/gcc/d/dmd/dcast.d
@@ -629,7 +629,7 @@ MATCH implicitConvTo(Expression e, Type t)
 
 TY tyn = e.type.nextOf().ty;
 
-if (!tyn.isSomeChar)
+if (!tyn.isSomeChar && !e.hexString)
 return visit(e);
 
 switch (t.ty)
@@ -703,6 +703,11 @@ MATCH implicitConvTo(Expression e, Type t)
 return MATCH.nomatch;
 m = MATCH.constant;
 }
+if (e.hexString && tn.isintegral && (tn.size == e.sz || 
(!e.committed && (e.len % tn.size) == 0)))
+{
+m = MATCH.convert;
+return m;
+}
 if (!e.committed)
 {
 switch (tn.ty)
@@ -719,9 +724,6 @@ MATCH implicitConvTo(Expression e, Type t)
 if (e.postfix != 'd')
 m = MATCH.convert;
 return m;
-case Tint8:
-   

Re: [PATCH] libphobos, Darwin: Enable libphobos for most Darwin.

2024-04-02 Thread Iain Buclaw
Excerpts from Iain Sandoe's message of April 2, 2024 1:51 pm:
> I have been building and testing D/libphobos for some time and over
> some GCC and OS releases.  As discussed on IRC a while ago, I think
> we're ready to enable this (it also avoids an annoying build fail at
> stage 2 if one forgets to add the enable to the command line).
> 
> Also tested on x86_64 and powerpc64 linux gnu.
> 
> OK for trunk?
> OK for backports?
> thanks,
> Iain
> 

If you're confident, OK, let's enable it.

Iain.


[committed] d: Merge upstream dmd, druntime b65767825f, phobos 92dc5a4e9.

2024-04-06 Thread Iain Buclaw
Hi,

This patch merges the D front-end and runtime library with upstream dmd
b65767825f, and the standard library with phobos 92dc5a4e9.

Synchronizing with the upstream release of v2.108.0.

D front-end changes:

- Import dmd v2.108.0.

D runtime changes:

- Import druntime v2.108.0.

Phobos changes:

- Import phobos v2.108.0.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd b65767825f.
* dmd/VERSION: Bump version to v2.108.0.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime b65767825f.
* src/MERGE: Merge upstream phobos 92dc5a4e9.
---
 gcc/d/dmd/MERGE   |  2 +-
 gcc/d/dmd/VERSION |  2 +-
 libphobos/libdruntime/MERGE   |  2 +-
 .../core/internal/array/duplication.d | 14 +-
 libphobos/src/MERGE   |  2 +-
 .../building_blocks/kernighan_ritchie.d   |  4 +-
 libphobos/src/std/net/curl.d  |  5 +-
 libphobos/src/std/typecons.d  | 47 ++-
 8 files changed, 68 insertions(+), 10 deletions(-)

diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index a00872ef864..dc47db87a80 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-855353a1d9e16d43e85b6cf2b03aef388619bd16
+b65767825f365dbc153457fc86e1054b03196c6d
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/VERSION b/gcc/d/dmd/VERSION
index 8ca452f8912..5868b874955 100644
--- a/gcc/d/dmd/VERSION
+++ b/gcc/d/dmd/VERSION
@@ -1 +1 @@
-v2.108.0-rc.1
+v2.108.0
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index a00872ef864..dc47db87a80 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-855353a1d9e16d43e85b6cf2b03aef388619bd16
+b65767825f365dbc153457fc86e1054b03196c6d
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/libphobos/libdruntime/core/internal/array/duplication.d 
b/libphobos/libdruntime/core/internal/array/duplication.d
index eec6af92fef..9df84893bb9 100644
--- a/libphobos/libdruntime/core/internal/array/duplication.d
+++ b/libphobos/libdruntime/core/internal/array/duplication.d
@@ -21,9 +21,9 @@ U[] _dup(T, U)(scope T[] a) pure nothrow @trusted if 
(__traits(isPOD, T))
 {
 import core.stdc.string : memcpy;
 import core.internal.array.construction: _d_newarrayUPureNothrow;
-auto arr = _d_newarrayUPureNothrow!T(a.length, is(T == shared));
+auto arr = _d_newarrayUPureNothrow!U(a.length, is(U == shared));
 memcpy(cast(void*) arr.ptr, cast(const(void)*) a.ptr, T.sizeof * 
a.length);
-return *cast(U[]*) &arr;
+return arr;
 }
 }
 
@@ -358,3 +358,13 @@ U[] _dup(T, U)(T[] a) if (!__traits(isPOD, T))
 static assert(test!Copy());
 assert(test!Copy());
 }
+
+// https://issues.dlang.org/show_bug.cgi?id=24453
+@safe unittest
+{
+static inout(char)[] foo(ref scope return inout(char)[] s)
+{
+auto bla = s.idup;
+return s;
+}
+}
diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE
index ff34bece2a3..a4f25db810e 100644
--- a/libphobos/src/MERGE
+++ b/libphobos/src/MERGE
@@ -1,4 +1,4 @@
-a2ade9dec49e70c6acd447df52321988a4c2fb9f
+92dc5a4e98591a0e6b0af4ff0f84f096fea09016
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/phobos repository.
diff --git 
a/libphobos/src/std/experimental/allocator/building_blocks/kernighan_ritchie.d 
b/libphobos/src/std/experimental/allocator/building_blocks/kernighan_ritchie.d
index 6883d33adae..167cf1bc6bc 100644
--- 
a/libphobos/src/std/experimental/allocator/building_blocks/kernighan_ritchie.d
+++ 
b/libphobos/src/std/experimental/allocator/building_blocks/kernighan_ritchie.d
@@ -647,7 +647,7 @@ fronting the GC allocator.
 import std.experimental.allocator.gc_allocator : GCAllocator;
 import std.typecons : Ternary;
 // KRRegion fronting a general-purpose allocator
-ubyte[1024 * 128] buf;
+align(KRRegion!().alignment) ubyte[1024 * 128] buf;
 auto alloc = fallbackAllocator(KRRegion!()(buf), GCAllocator.instance);
 auto b = alloc.allocate(100);
 assert(b.length == 100);
@@ -916,7 +916,7 @@ version (StdUnittest)
 @system unittest
 {   import std.typecons : Ternary;
 
-ubyte[1024] b;
+align(KRRegion!().alignment) ubyte[1024] b;
 auto alloc = KRRegion!()(b);
 
 auto k = alloc.allocate(128);
diff --git a/libphobos/src/std/net/curl.d b/libphobos/src/std/net/curl.d
index 6aec366c657..3f823013e65 100644
--- a/libphobos/src/std/net/curl.d
+++ b/libphobos/src/std/net/curl.d
@@ -2422,6 +2422,7 @@ struct HTTP
 import std.algorithm.searching : findSplit, startsWith;
 im

[committed] d: Merge dmd. druntime e770945277, phobos 6d6e0b9b9

2024-02-03 Thread Iain Buclaw
Hi,

This patch merges the D front-end and runtime library with upstream dmd
e770945277, and the standard runtime library with phobos 6d6e0b9b9.

Synchronizing with the upstream release candidate as of 2024-01-27.

D front-end changes:

- Import latest fixes from dmd v2.107.0-beta.1.
- Hex strings can now be cast to integer arrays.
- Add support for Interpolated Expression Sequences.

D runtime changes:

- Import latest fixes from druntime v2.107.0-beta.1.
- New core.interpolation module to provide run-time support for D
  interpolated expression sequence literals.

Phobos changes:

- Import latest fixes from phobos v2.107.0-beta.1.
- `std.range.primitives.isBidirectionalRange', and
  `std.range.primitives.isRandomAccessRange' now take an optional
  element type.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd e770945277.
* Make-lang.in (D_FRONTEND_OBJS): Add d/basicmangle.o, d/enumsem.o,
d/funcsem.o, d/templatesem.o.
* d-builtins.cc (build_frontend_type): Update for new front-end
interface.
* d-codegen.cc (declaration_type): Likewise.
(parameter_type): Likewise.
* d-incpath.cc (add_globalpaths): Likewise.
(add_filepaths): Likewise.
(add_import_paths): Likewise.
* d-lang.cc (d_init_options): Likewise.
(d_handle_option): Likewise.
(d_parse_file): Likewise.
* decl.cc (DeclVisitor::finish_vtable): Likewise.
(DeclVisitor::visit (FuncDeclaration *)): Likewise.
(get_symbol_decl): Likewise.
* expr.cc (ExprVisitor::visit (StringExp *)): Likewise.
Implement support for 8-byte hexadecimal strings.
* typeinfo.cc (create_tinfo_types): Update internal TypeInfo
representation.
(TypeInfoVisitor::visit (TypeInfoConstDeclaration *)): Update for new
front-end interface.
(TypeInfoVisitor::visit (TypeInfoInvariantDeclaration *)): Likewise.
(TypeInfoVisitor::visit (TypeInfoSharedDeclaration *)): Likewise.
(TypeInfoVisitor::visit (TypeInfoWildDeclaration *)): Likewise.
(TypeInfoVisitor::visit (TypeInfoClassDeclaration *)): Move data for
TypeInfo_Class.nameSig to the end of the object.
(create_typeinfo): Update for new front-end interface.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime e770945277.
* libdruntime/Makefile.am (DRUNTIME_SOURCES): Add
core/interpolation.d.
* libdruntime/Makefile.in: Regenerate.
* src/MERGE: Merge upstream phobos 6d6e0b9b9.
---
 gcc/d/Make-lang.in|4 +
 gcc/d/d-builtins.cc   |2 +-
 gcc/d/d-codegen.cc|4 +-
 gcc/d/d-incpath.cc|   41 +-
 gcc/d/d-lang.cc   |   34 +-
 gcc/d/decl.cc |   37 +-
 gcc/d/dmd/MERGE   |2 +-
 gcc/d/dmd/README.md   |4 +
 gcc/d/dmd/aggregate.h |3 +-
 gcc/d/dmd/basicmangle.d   |  109 ++
 gcc/d/dmd/clone.d |9 +-
 gcc/d/dmd/common/outbuffer.d  |   27 +
 gcc/d/dmd/cond.d  |   19 +-
 gcc/d/dmd/constfold.d |6 +-
 gcc/d/dmd/ctfeexpr.d  |   10 +-
 gcc/d/dmd/dclass.d|2 +
 gcc/d/dmd/declaration.h   |7 +-
 gcc/d/dmd/denum.d |   85 -
 gcc/d/dmd/dinterpret.d|   68 +-
 gcc/d/dmd/dmangle.d   |  144 +-
 gcc/d/dmd/dmodule.d   |6 +-
 gcc/d/dmd/doc.d   |3 +-
 gcc/d/dmd/dstruct.d   |2 +-
 gcc/d/dmd/dsymbolsem.d|  574 +-
 gcc/d/dmd/dtemplate.d | 1646 +
 gcc/d/dmd/enum.h  |2 -
 gcc/d/dmd/enumsem.d   |  714 +++
 gcc/d/dmd/expression.d|   44 +-
 gcc/d/dmd/expression.h|   15 +-
 gcc/d/dmd/expressionsem.d |  103 +-
 gcc/d/dmd/func.d  |  199 +-
 gcc/d/dmd/funcsem.d   |  219 +++
 gcc/d/dmd/globals.d   |   12 +-
 gcc/d/dmd/globals.h   |   12 +-
 gcc/d/dmd/hdrgen.d|   84 +
 gcc/d/dmd/id.d|6 +
 gcc/d/dmd/json.d  |   14 +-
 gcc/d/dmd/lexer.d |  166 +-
 gcc/d/dmd/mtype.d |   56 +-
 gcc/d/dmd/mtype.h |2

[committed] d: Merge dmd, druntime a6f1083699, phobos 31dedd7da

2024-02-03 Thread Iain Buclaw
Hi,

This patch merges the D front-end and runtime library with upstream dmd
a6f1083699, and the standard library with phobos 31dedd7da.

D front-end changes:

- Import dmd v2.107.0.
- Character postfixes can now also be used for integers of size
  two or four.

D run-time changes:

- Import druntime v2.107.0.

Phobos changes:

- Import phobos v2.107.0.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd a6f1083699.
* dmd/VERSION: Bump version to v2.107.0
* Make-lang.in (D_FRONTEND_OBJS): Add d/pragmasem.o.
* d-builtins.cc (strip_type_modifiers): Update for new front-end
interface.
* d-codegen.cc (declaration_type): Likewise.
(parameter_type): Likewise.
* d-target.cc (TargetCPP::parameterType): Likewise.
* expr.cc (ExprVisitor::visit (IndexExp *)): Likewise.
(ExprVisitor::visit (VarExp *)): Likewise.
(ExprVisitor::visit (AssocArrayLiteralExp *)): Likewise.
* runtime.cc (get_libcall_type): Likewise.
* typeinfo.cc (TypeInfoVisitor::visit (TypeInfoConstDeclaration *)):
Likewise.
(TypeInfoVisitor::visit (TypeInfoInvariantDeclaration *)): Likewise.
(TypeInfoVisitor::visit (TypeInfoSharedDeclaration *)): Likewise.
(TypeInfoVisitor::visit (TypeInfoWildDeclaration *)): Likewise.
* types.cc (build_ctype): Likewise.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime a6f1083699.
* src/MERGE: Merge upstream phobos 31dedd7da.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
 gcc/d/Make-lang.in|1 +
 gcc/d/d-builtins.cc   |2 +-
 gcc/d/d-codegen.cc|4 +-
 gcc/d/d-target.cc |4 +-
 gcc/d/dmd/MERGE   |2 +-
 gcc/d/dmd/README.md   |1 +
 gcc/d/dmd/VERSION |2 +-
 gcc/d/dmd/constfold.d |6 +-
 gcc/d/dmd/cparse.d|2 +-
 gcc/d/dmd/ctfeexpr.d  |2 +-
 gcc/d/dmd/dcast.d |   20 +-
 gcc/d/dmd/dclass.d|1 +
 gcc/d/dmd/declaration.h   |1 -
 gcc/d/dmd/denum.d |7 +-
 gcc/d/dmd/dinterpret.d|   43 +-
 gcc/d/dmd/dmangle.d   |   20 +-
 gcc/d/dmd/dsymbol.h   |2 +-
 gcc/d/dmd/dsymbolsem.d| 1888 ++---
 gcc/d/dmd/dtemplate.d |  759 +--
 gcc/d/dmd/dtoh.d  |1 +
 gcc/d/dmd/enumsem.d   |6 +
 gcc/d/dmd/expression.d|3 +-
 gcc/d/dmd/expression.h|3 +-
 gcc/d/dmd/expressionsem.d |   31 +-
 gcc/d/dmd/func.d  |  172 +-
 gcc/d/dmd/funcsem.d   | 1150 ++
 gcc/d/dmd/hdrgen.d|3 +-
 gcc/d/dmd/initsem.d   |   86 +-
 gcc/d/dmd/mtype.d |  353 +--
 gcc/d/dmd/mtype.h |   26 +-
 gcc/d/dmd/opover.d|1 +
 gcc/d/dmd/optimize.d  |3 +-
 gcc/d/dmd/pragmasem.d |  650 ++
 gcc/d/dmd/scope.h |2 +-
 gcc/d/dmd/semantic2.d |   23 +-
 gcc/d/dmd/sideeffect.d|   10 +
 gcc/d/dmd/statementsem.d  |  181 +-
 gcc/d/dmd/templatesem.d   |  909 +++-
 gcc/d/dmd/typesem.d   |  304 ++-
 gcc/d/dmd/utils.d |   41 +
 gcc/d/expr.cc |9 +-
 gcc/d/runtime.cc  |6 +-
 gcc/d/typeinfo.cc |8 +-
 gcc/d/types.cc|2 +-
 gcc/testsuite/gdc.test/compilable/ddoc4162.d  |2 +-
 gcc/testsuite/gdc.test/compilable/ddoc5446.d  |2 +-
 gcc/testsuite/gdc.test/compilable/ddoc7795.d  |2 +-
 .../compilable/{ddoc12.d => ddoc_bom_UTF8.d}  |0
 gcc/testsuite/gdc.test/compilable/test24338.d |   10 +
 .../gdc.test/fail_compilation/discard_value.d |   34 +
 .../gdc.test/fail_compilation/fail12390.d |   16 -
 .../gdc.test/fail_compilation/gag4269a.d  |2 +-
 .../gdc.test/fail_compilation/gag4269b.d  |2 +-
 .../gdc.test/fail_compilation/gag4269c.d  |2 +-
 .../gdc.test/fail_compilation/gag4269d.d  |2 +-
 .../gdc.test/fail_compilation/gag4269e.d  |2 +-
 .../gdc.test/fail_compilation/gag4269f.d  |2 +-
 .../gdc.test/fail_compilation/gag4269g.d  |2 +-
 .../gdc.te

[committed] d: Merge dmd, druntime 11240a9663

2024-02-12 Thread Iain Buclaw
Hi,

This patch merges the D front-end and core runtime library with upstream
dmd 11240a9663.

Included in the merge are the fix for PR113772, and new testsuite
directives to enable fixing PR104739.

D front-end changes:

- Import latest fixes from dmd v2.107.0.

D runtime changes:

- Import latest fixes from druntime v2.107.0.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
PR d/113772

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 11240a9663.
* d-builtins.cc (build_frontend_type): Update for new front-end
interface.
* types.cc (same_type_p): Likewise.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 11240a9663.
---
 gcc/d/d-builtins.cc   |  31 ++--
 gcc/d/dmd/MERGE   |   2 +-
 gcc/d/dmd/aggregate.d |   2 +-
 gcc/d/dmd/aggregate.h |   1 +
 gcc/d/dmd/astcodegen.d|   1 +
 gcc/d/dmd/astenums.d  |   2 +-
 gcc/d/dmd/clone.d |  17 +-
 gcc/d/dmd/constfold.d |   2 +-
 gcc/d/dmd/dcast.d |  87 +-
 gcc/d/dmd/declaration.d   |   4 +-
 gcc/d/dmd/declaration.h   |   2 -
 gcc/d/dmd/dinterpret.d|   2 +-
 gcc/d/dmd/dsymbol.h   |   2 -
 gcc/d/dmd/dsymbolsem.d|   2 +-
 gcc/d/dmd/errors.h|   2 -
 gcc/d/dmd/expression.h|  10 +-
 gcc/d/dmd/expressionsem.d |  34 ++--
 gcc/d/dmd/func.d  |  11 +-
 gcc/d/dmd/hdrgen.h|   8 +
 gcc/d/dmd/init.h  |   1 +
 gcc/d/dmd/mtype.d | 112 +---
 gcc/d/dmd/mtype.h |   6 +-
 gcc/d/dmd/parse.d |   2 +-
 gcc/d/dmd/statement.h |   5 +
 gcc/d/dmd/template.h  |   3 +
 gcc/d/dmd/typesem.d   | 112 +++-
 gcc/d/types.cc|   2 +-
 .../gdc.test/compilable/commontype.d  |  20 +--
 gcc/testsuite/gdc.test/compilable/test3543.d  |  80 +
 gcc/testsuite/gdc.test/runnable/mangle.d  |   1 +
 gcc/testsuite/gdc.test/runnable/testmodule.d  |   2 +
 gcc/testsuite/gdc.test/runnable/ufcs.d|   2 +
 libphobos/libdruntime/MERGE   |   2 +-
 libphobos/libdruntime/core/demangle.d | 160 +-
 libphobos/libdruntime/core/internal/atomic.d  |   2 +-
 .../core/internal/gc/impl/conservative/gc.d   |  39 +++--
 libphobos/libdruntime/core/internal/qsort.d   |   5 +-
 libphobos/libdruntime/core/memory.d   |   1 +
 libphobos/libdruntime/core/thread/osthread.d  |   2 +
 libphobos/libdruntime/core/time.d |   4 +
 libphobos/libdruntime/rt/aaA.d|   1 +
 libphobos/libdruntime/rt/lifetime.d   |   1 +
 42 files changed, 491 insertions(+), 296 deletions(-)
 create mode 100644 gcc/testsuite/gdc.test/compilable/test3543.d

diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc
index 4ed8751079b..24ac456e23d 100644
--- a/gcc/d/d-builtins.cc
+++ b/gcc/d/d-builtins.cc
@@ -97,12 +97,15 @@ build_frontend_type (tree type)
{
  /* Check for char * first.  Needs to be done for chars/string.  */
  if (TYPE_MAIN_VARIANT (TREE_TYPE (type)) == char_type_node)
-   return Type::tchar->addMod (dtype->mod)->pointerTo ()->addMod (mod);
+   {
+ dtype = addMod (Type::tchar, dtype->mod);
+ return addMod (dtype->pointerTo (), mod);
+   }
 
  if (dtype->ty == TY::Tfunction)
-   return (TypePointer::create (dtype))->addMod (mod);
+   return addMod (TypePointer::create (dtype), mod);
 
- return dtype->pointerTo ()->addMod (mod);
+ return addMod (dtype->pointerTo (), mod);
}
   break;
 
@@ -113,7 +116,7 @@ build_frontend_type (tree type)
  /* Want to assign ctype directly so that the REFERENCE_TYPE code
 can be turned into as an `inout' argument.  Can't use pointerTo(),
 because the returned Type is shared.  */
- dtype = (TypePointer::create (dtype))->addMod (mod);
+ dtype = addMod (TypePointer::create (dtype), mod);
  dtype->ctype = type;
  builtin_converted_decls.safe_push (builtin_data (dtype, type));
  return dtype;
@@ -122,7 +125,7 @@ build_frontend_type (tree type)
 
 case BOOLEAN_TYPE:
   /* Should be no need for size checking.  */
-  return Type::tbool->addMod (mod);
+  return addMod (Type::tbool, mod);
 
 case INTEGER_TYPE:
 {
@@ -140,7 +143,7 @@ build_frontend_type (tree type)
  || size != dt

[committed] d: Fix callee destructor call invalidates the live object [PR113758]

2024-02-12 Thread Iain Buclaw
Hi,

This patch fixes code generation problem with passing objects by
invisible reference - because of a defined cpctor or dtor.

When generating the argument, check the isCalleeDestroyingArgs hook, and
force a TARGET_EXPR to be created if true, so that a reference to the
live object isn't passed directly to the function that runs dtors.

When instead dealing with caller running destructors, two temporaries
were being generated, one explicit temporary generated by the D
front-end, and another implicitly by the code generator.  This has been
reduced to one by setting DECL_VALUE_EXPR on the explicit temporary to
bind it to the implicit slot created for the TARGET_EXPR, as that has
the shorter lifetime of the two.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
PR d/113758

gcc/d/ChangeLog:

* d-codegen.cc (d_build_call): Force a TARGET_EXPR when callee
destorys its arguments.
* decl.cc (DeclVisitor::visit (VarDeclaration *)): Set
SET_DECL_VALUE_EXPR on the temporary variable to make it a placeholder
for the TARGET_EXPR_SLOT.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/pr113758.d: New test.
---
 gcc/d/d-codegen.cc  | 15 +++
 gcc/d/decl.cc   | 22 --
 gcc/testsuite/gdc.dg/torture/pr113758.d | 19 +++
 3 files changed, 50 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/torture/pr113758.d

diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 95dc8b6327e..dc528164aaf 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -2270,10 +2270,17 @@ d_build_call (TypeFunction *tf, tree callable, tree 
object,
  Type *t = arg->type->toBasetype ();
  StructDeclaration *sd = t->baseElemOf ()->isTypeStruct ()->sym;
 
- /* Nested structs also have ADDRESSABLE set, but if the type has
-neither a copy constructor nor a destructor available, then we
-need to take care of copying its value before passing it.  */
- if (arg->op == EXP::structLiteral || (!sd->postblit && !sd->dtor))
+ /* Need to take care of copying its value before passing the
+argument in the following scenarios:
+- The argument is a literal expression; a CONSTRUCTOR can't
+have its address taken.
+- The type has neither a copy constructor nor a destructor
+available; nested structs also have ADDRESSABLE set.
+- The ABI of the function expects the callee to destroy its
+arguments; when the caller is handles destruction, then `targ'
+has already been made into a temporary. */
+ if (arg->op == EXP::structLiteral || (!sd->postblit && !sd->dtor)
+ || target.isCalleeDestroyingArgs (tf))
targ = force_target_expr (targ);
 
  targ = convert (build_reference_type (TREE_TYPE (targ)),
diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index d2e84d3ba61..827495b3e30 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -863,10 +863,28 @@ public:
/* Maybe put variable on list of things needing destruction.  */
if (d->needsScopeDtor ())
  {
+   /* Rewrite: `decl = exp' => TARGET_EXPR(decl, exp, dtor).  */
vec_safe_push (d_function_chain->vars_in_scope, decl);
+
/* Force a TARGET_EXPR to add the corresponding cleanup.  */
-   exp = force_target_expr (compound_expr (exp, decl));
-   TARGET_EXPR_CLEANUP (exp) = build_expr (d->edtor);
+   if (TREE_CODE (exp) != TARGET_EXPR)
+ {
+   if (VOID_TYPE_P (TREE_TYPE (exp)))
+ exp = compound_expr (exp, decl);
+
+   exp = force_target_expr (exp);
+ }
+
+   TARGET_EXPR_CLEANUP (exp)
+ = compound_expr (TARGET_EXPR_CLEANUP (exp),
+  build_expr (d->edtor));
+
+   /* The decl is really an alias for the TARGET_EXPR slot.  */
+   SET_DECL_VALUE_EXPR (decl, TARGET_EXPR_SLOT (exp));
+   DECL_HAS_VALUE_EXPR_P (decl) = 1;
+   /* This tells the gimplifier not to emit a clobber for the decl
+  as its lifetime ends when the slot gets cleaned up.  */
+   TREE_ADDRESSABLE (decl) = 0;
  }
 
add_stmt (exp);
diff --git a/gcc/testsuite/gdc.dg/torture/pr113758.d 
b/gcc/testsuite/gdc.dg/torture/pr113758.d
new file mode 100644
index 000..dc53883a8de
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/torture/pr113758.d
@@ -0,0 +1,19 @@
+// { dg-do run }
+// { dg-skip-if "needs gcc/config.d" { ! d_runtime } }
+struct S113758
+{
+int field;
+~this() { field = 0; }
+}
+
+void main()
+{
+auto var = S113758(1);
+  

[committed] d: Fix internal compiler error: in make_import, at d/imports.cc:48 [PR113125]

2024-02-12 Thread Iain Buclaw
Hi,

This patch fixes an ICE triggered in the D front-end.

The cause of the ICE was that TYPE_DECLs were only being generated for
structs with members, not opaque structs.

PR d/113125

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---

gcc/d/ChangeLog:

* types.cc (TypeVisitor::visit (TypeStruct *)): Generate TYPE_DECL and
apply UDAs to opaque struct declarations.

gcc/testsuite/ChangeLog:

* gdc.dg/imports/pr113125.d: New test.
* gdc.dg/pr113125.d: New test.
---
 gcc/d/types.cc  | 5 +
 gcc/testsuite/gdc.dg/imports/pr113125.d | 2 ++
 gcc/testsuite/gdc.dg/pr113125.d | 4 
 3 files changed, 11 insertions(+)
 create mode 100644 gcc/testsuite/gdc.dg/imports/pr113125.d
 create mode 100644 gcc/testsuite/gdc.dg/pr113125.d

diff --git a/gcc/d/types.cc b/gcc/d/types.cc
index af9aad8a412..ed97aa39cc5 100644
--- a/gcc/d/types.cc
+++ b/gcc/d/types.cc
@@ -1230,6 +1230,11 @@ public:
apply_user_attributes (t->sym, t->ctype);
finish_aggregate_type (structsize, alignsize, t->ctype);
   }
+else
+  {
+   build_type_decl (t->ctype, t->sym);
+   apply_user_attributes (t->sym, t->ctype);
+  }
 
 /* For structs with a user defined postblit, copy constructor, or a
destructor, also set TREE_ADDRESSABLE on the type and all variants.
diff --git a/gcc/testsuite/gdc.dg/imports/pr113125.d 
b/gcc/testsuite/gdc.dg/imports/pr113125.d
new file mode 100644
index 000..761e613b055
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/imports/pr113125.d
@@ -0,0 +1,2 @@
+module imports.pr113125;
+struct S113125;
diff --git a/gcc/testsuite/gdc.dg/pr113125.d b/gcc/testsuite/gdc.dg/pr113125.d
new file mode 100644
index 000..cb7300baa1a
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr113125.d
@@ -0,0 +1,4 @@
+// { dg-do compile }
+// { dg-options "-I $srcdir/gdc.dg" }
+module pr113125;
+import imports.pr113125: S113125;
-- 
2.40.1



[committed] libphobos: Bump soname version to 5 [PR113667]

2024-02-12 Thread Iain Buclaw
Hi,

This patch bumps the soname version of libphobos.

Each major release is not binary compatible with the previous.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
PR d/113667

libphobos/ChangeLog:

* configure: Regenerate.
* configure.ac (libtool_VERSION): Update to 5:0:0.
---
 libphobos/configure| 2 +-
 libphobos/configure.ac | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libphobos/configure b/libphobos/configure
index 9a59bad34ac..9b6a41879d3 100755
--- a/libphobos/configure
+++ b/libphobos/configure
@@ -15741,7 +15741,7 @@ SPEC_PHOBOS_DEPS="$LIBS"
 
 
 # Libdruntime / phobos soname version
-libtool_VERSION=4:0:0
+libtool_VERSION=5:0:0
 
 
 # Set default flags (after DRUNTIME_WERROR!)
diff --git a/libphobos/configure.ac b/libphobos/configure.ac
index bce85388612..ab82eacc204 100644
--- a/libphobos/configure.ac
+++ b/libphobos/configure.ac
@@ -258,7 +258,7 @@ SPEC_PHOBOS_DEPS="$LIBS"
 AC_SUBST(SPEC_PHOBOS_DEPS)
 
 # Libdruntime / phobos soname version
-libtool_VERSION=4:0:0
+libtool_VERSION=5:0:0
 AC_SUBST(libtool_VERSION)
 
 # Set default flags (after DRUNTIME_WERROR!)
-- 
2.40.1



Re: [PATCH] testsuite: gdc: Require ucn in gdc.test/runnable/mangle.d etc. [PR104739]

2024-02-14 Thread Iain Buclaw
Excerpts from Rainer Orth's message of Februar 14, 2024 11:51 am:
> gdc.test/runnable/mangle.d and two other tests come out UNRESOLVED on
> Solaris with the native assembler:
> 
> UNRESOLVED: gdc.test/runnable/mangle.d   compilation failed to produce 
> executable
> UNRESOLVED: gdc.test/runnable/mangle.d -shared-libphobos   compilation failed 
> to produce executable
> UNRESOLVED: gdc.test/runnable/testmodule.d   compilation failed to produce 
> executable 
> UNRESOLVED: gdc.test/runnable/testmodule.d -shared-libphobos   compilation 
> failed to produce executable
> UNRESOLVED: gdc.test/runnable/ufcs.d   compilation failed to produce 
> executable
> UNRESOLVED: gdc.test/runnable/ufcs.d -shared-libphobos   compilation failed 
> to produce executable
> 
> Assembler: mangle.d
> "/var/tmp//cci9q2Sc.s", line 115 : Syntax error
> Near line: "movzbl  test_эльфийские_письмена_9, %eax"
> "/var/tmp//cci9q2Sc.s", line 115 : Syntax error
> Near line: "movzbl  test_эльфийские_письмена_9, %eax"
> "/var/tmp//cci9q2Sc.s", line 115 : Syntax error
> Near line: "movzbl  test_эльфийские_письмена_9, %eax"
> "/var/tmp//cci9q2Sc.s", line 115 : Syntax error
> Near line: "movzbl  test_эльфийские_письмена_9, %eax"
> "/var/tmp//cci9q2Sc.s", line 115 : Syntax error
> [...]
> 
> since /bin/as lacks UCN support.
> 
> Iain recently added UNICODE_NAMES: annotations to the affected tests and
> those recently were imported into trunk.
> 
> This patch handles the DejaGnu side of things, adding
> 
>   { dg-require-effective-target ucn }
> 
> to those tests on the fly.
> 
> Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11 (as and gas each),
> and x86_64-pc-linux-gnu.
> 
> Ok for trunk.
> 

OK.

Thanks!
Iain.


[committed] d: Add UTF BOM tests to gdc.dg testsuite

2024-02-19 Thread Iain Buclaw
Hi,

This patch checks in a few combinations of UTF BOM/no-BOM tests to the
gdc.dg testsuite.

Some of these are part of the upstream DMD `gdc.test' testsuite, but
they had been omitted because they get mangled by the lib/gdc-utils.exp
helpers when parsing and staging the tests. Translate them over to the
gdc.dg testsuite instead.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
gcc/testsuite/ChangeLog:

* gdc.dg/bom_UTF16BE.d: New test.
* gdc.dg/bom_UTF16LE.d: New test.
* gdc.dg/bom_UTF32BE.d: New test.
* gdc.dg/bom_UTF32LE.d: New test.
* gdc.dg/bom_UTF8.d: New test.
* gdc.dg/bom_characters.d: New test.
* gdc.dg/bom_error_UTF8.d: New test.
* gdc.dg/bom_infer_UTF16BE.d: New test.
* gdc.dg/bom_infer_UTF16LE.d: New test.
* gdc.dg/bom_infer_UTF32BE.d: New test.
* gdc.dg/bom_infer_UTF32LE.d: New test.
* gdc.dg/bom_infer_UTF8.d: New test.
---
 gcc/testsuite/gdc.dg/bom_UTF16BE.d   | Bin 0 -> 300 bytes
 gcc/testsuite/gdc.dg/bom_UTF16LE.d   | Bin 0 -> 300 bytes
 gcc/testsuite/gdc.dg/bom_UTF32BE.d   | Bin 0 -> 556 bytes
 gcc/testsuite/gdc.dg/bom_UTF32LE.d   | Bin 0 -> 556 bytes
 gcc/testsuite/gdc.dg/bom_UTF8.d  |  11 +++
 gcc/testsuite/gdc.dg/bom_characters.d| Bin 0 -> 780 bytes
 gcc/testsuite/gdc.dg/bom_error_UTF8.d|  11 +++
 gcc/testsuite/gdc.dg/bom_infer_UTF16BE.d | Bin 0 -> 298 bytes
 gcc/testsuite/gdc.dg/bom_infer_UTF16LE.d | Bin 0 -> 298 bytes
 gcc/testsuite/gdc.dg/bom_infer_UTF32BE.d | Bin 0 -> 552 bytes
 gcc/testsuite/gdc.dg/bom_infer_UTF32LE.d | Bin 0 -> 552 bytes
 gcc/testsuite/gdc.dg/bom_infer_UTF8.d|  11 +++
 12 files changed, 33 insertions(+)
 create mode 100644 gcc/testsuite/gdc.dg/bom_UTF16BE.d
 create mode 100644 gcc/testsuite/gdc.dg/bom_UTF16LE.d
 create mode 100644 gcc/testsuite/gdc.dg/bom_UTF32BE.d
 create mode 100644 gcc/testsuite/gdc.dg/bom_UTF32LE.d
 create mode 100644 gcc/testsuite/gdc.dg/bom_UTF8.d
 create mode 100644 gcc/testsuite/gdc.dg/bom_characters.d
 create mode 100644 gcc/testsuite/gdc.dg/bom_error_UTF8.d
 create mode 100644 gcc/testsuite/gdc.dg/bom_infer_UTF16BE.d
 create mode 100644 gcc/testsuite/gdc.dg/bom_infer_UTF16LE.d
 create mode 100644 gcc/testsuite/gdc.dg/bom_infer_UTF32BE.d
 create mode 100644 gcc/testsuite/gdc.dg/bom_infer_UTF32LE.d
 create mode 100644 gcc/testsuite/gdc.dg/bom_infer_UTF8.d

diff --git a/gcc/testsuite/gdc.dg/bom_UTF16BE.d 
b/gcc/testsuite/gdc.dg/bom_UTF16BE.d
new file mode 100644
index 
..f18cec9b1e597b96e27c8650bac552ccb5bde54e
GIT binary patch
literal 300
zcmY+9%?iRm41~Y4;5#fmwc_7dkG_T%-L6{cAGM-Te06np+kz5ynCv8z}60;*=6SPcuE2mmY&rj0*
zoRV8mEEf(^4KwD#Wr*a*d-Nz&=Xor5KeG#H)Z^oSLL^tGjq`BVL)eI??A0Hszu$c9
QZB*OpLchIXJ*eUOFJQ(j-2eap

literal 0
HcmV?d1

diff --git a/gcc/testsuite/gdc.dg/bom_UTF16LE.d 
b/gcc/testsuite/gdc.dg/bom_UTF16LE.d
new file mode 100644
index 
..e79a4ddbce1617edc38aa2b8aec61698d200461e
GIT binary patch
literal 300
zcmY+9%?iRm41~Y4;5#fmwW8Lu9{U$vtW9aoV
z&a8yBcq%Mu$SJVOU(A{5r$q~yP3U5qaGLk69TzfZCv=f9>P{UW3T=|{ln%{
RZ>!o)7rN~Yn^7IE{{oAqEZqPA

literal 0
HcmV?d1

diff --git a/gcc/testsuite/gdc.dg/bom_UTF32BE.d 
b/gcc/testsuite/gdc.dg/bom_UTF32BE.d
new file mode 100644
index 
..eaf3b04b458fe51bf8b3726af5970ded60f19ad6
GIT binary patch
literal 556
zcmaLUxvD}j5P;#-KE+_A;#O;UU&F?I!3`G_#8+4UUrr$0!r~*zoS9^jlhW&*QtDNL
z@d3vfmgrRT17lzc=Q|v+#ujq~o~Xg^=DE)mWsdO)Hn7e;FBrmF8Nb80^Aq-H;15j<
zV6Hv*&D?-}nP0{itgX%cn}0^GF}}hW)&^Q=SMx4o=GkSh)i8#A*_}0JB&L&VUGqzXkq|!
z?ZI#62JFlHJicIUZR+3rGg6K56~?eO&_cVKcNr7U&U?+z3BGxE_epWjwZ>k3U&r|I
uuje|s_U1eIj!OUIR?Y3%xbI!U`&pOw8mx2HxTkO6KXPqdppSIN^iMzHA1qD)

literal 0
HcmV?d1

diff --git a/gcc/testsuite/gdc.dg/bom_UTF8.d b/gcc/testsuite/gdc.dg/bom_UTF8.d
new file mode 100644
index 000..f3e8af4eb38
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/bom_UTF8.d
@@ -0,0 +1,11 @@
+// { dg-do compile }
+module object;
+
+extern(C):
+int printf(const char *, ...);
+
+int main()
+{
+printf("hello world\n");
+return 0;
+}
diff --git a/gcc/testsuite/gdc.dg/bom_characters.d 
b/gcc/testsuite/gdc.dg/bom_characters.d
new file mode 100644
index 
..4b42b4c611ba7b2746db7df9f3ba19c760952ae9
GIT binary patch
literal 780
zcmbW#&k6xi6vy#v3kP)nCCW)IL=_nmD43E|lBDznNEhmHjQV!*%7S&AjE~nKoyZSzRHXYqMsV_nyRa
iM|{5-WY~psx#)gdVZWN$q}}zS{5#*~AAZbl|LhCNt~kg5

literal 0
HcmV?d1

diff --git a/gcc/testsuite/gdc.dg/bom_error_UTF8.d 
b/gcc/testsuite/gdc.dg/bom_error_UTF8.d
new file mode 100644
index 000..0e47e59bda3
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/bom_error_UTF8.d
@@ -0,0 +1,11 @@
+// { dg-do compile }
+module object; // { dg-error "character 0xfeff is not a valid token" }
+
+extern(C):
+int 

Re: [PATCH v10 2/2] Add gcov MC/DC tests for GDC

2024-02-23 Thread Iain Buclaw
Excerpts from Jørgen Kvalsvik's message of Februar 23, 2024 12:18 pm:
> This is a mostly straight port from the gcov-19.c tests from the C test
> suite. The only notable differences from C to D are that D flips the
> true/false outcomes for loop headers, and the D front end ties loop and
> ternary conditions to slightly different locus.
> 
> The test for >64 conditions warning is disabled as it either needs
> support from the testing framework or a something similar to #pragma GCC
> diagnostic push to not cause a test failure from detecting a warning.
> 
> gcc/testsuite/ChangeLog:
> 
>   * gdc.dg/gcov.exp: New test.
>   * gdc.dg/gcov1.d: New test.
> ---
>  gcc/testsuite/gdc.dg/gcov.exp |   44 +
>  gcc/testsuite/gdc.dg/gcov1.d  | 1712 +
>  2 files changed, 1756 insertions(+)
>  create mode 100644 gcc/testsuite/gdc.dg/gcov.exp
>  create mode 100644 gcc/testsuite/gdc.dg/gcov1.d
> 

I think I said this before in the previous series, no objections to
adding more tests to the gdc testsuite.

OK.

Thanks,
Iain.


[committed] d: Merge dmd, druntime ceff48bf7d, phobos dcbfbd43a

2024-02-25 Thread Iain Buclaw
Hi,

This patch merges the D front-end and runtime library with upstream dmd
ceff48bf7d, and the standard library with phobos dcbfbd43a.

D front-end changes:

-   Import latest fixes from dmd v2.107.1-rc.1.

D runtime changes:

-   Import latest fixes from druntime v2.107.1-rc.1.

Phobos changes:

-   Import latest fixes from phobos v2.107.1-rc.1.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd ceff48bf7d.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime ceff48bf7d.
* libdruntime/Makefile.am (DRUNTIME_DSOURCES_FREEBSD): Add
core/sys/freebsd/net/if_.d.
* libdruntime/Makefile.in: Regenerate.
* src/MERGE: Merge upstream phobos dcbfbd43a.
---
 gcc/d/dmd/MERGE   |   2 +-
 gcc/d/dmd/arrayop.d   |   2 +-
 gcc/d/dmd/ast_node.h  |   2 +-
 gcc/d/dmd/common/file.d   |  89 ++--
 gcc/d/dmd/common/smallbuffer.d|  30 +-
 gcc/d/dmd/cparse.d| 150 +-
 gcc/d/dmd/dimport.d   | 109 +---
 gcc/d/dmd/dmodule.d   |  32 +-
 gcc/d/dmd/dsymbolsem.d|  97 
 gcc/d/dmd/expression.d|   4 +-
 gcc/d/dmd/expression.h|   2 +-
 gcc/d/dmd/expressionsem.d |  97 
 gcc/d/dmd/func.d  | 394 +-
 gcc/d/dmd/funcsem.d   | 390 ++
 gcc/d/dmd/identifier.h|   2 +-
 gcc/d/dmd/importc.d   |   7 +-
 gcc/d/dmd/mtype.d |   1 -
 gcc/d/dmd/parse.d |  48 +-
 gcc/d/dmd/root/array.h|   3 +-
 gcc/d/dmd/root/bitarray.h |   1 -
 gcc/d/dmd/{root/object.h => rootobject.h} |   6 +-
 gcc/d/dmd/statementsem.d  |   2 +-
 gcc/d/dmd/staticcond.d| 107 
 gcc/d/dmd/template.h  |   2 +-
 .../gdc.test/compilable/imports/defines.c |  25 +
 .../gdc.test/compilable/testdefines.d |  10 +
 .../gdc.test/fail_compilation/warn13679.d |   4 +-
 libphobos/libdruntime/MERGE   |   2 +-
 libphobos/libdruntime/Makefile.am |  22 +-
 libphobos/libdruntime/Makefile.in |  31 +-
 .../libdruntime/core/sys/freebsd/ifaddrs.d|   3 +-
 .../libdruntime/core/sys/freebsd/net/if_.d| 493 ++
 .../libdruntime/core/sys/linux/sys/socket.d   |   1 -
 libphobos/libdruntime/core/thread/fiber.d |   2 +-
 libphobos/src/MERGE   |   2 +-
 libphobos/src/std/typecons.d  |  35 +-
 36 files changed, 1417 insertions(+), 792 deletions(-)
 rename gcc/d/dmd/{root/object.h => rootobject.h} (91%)
 create mode 100644 libphobos/libdruntime/core/sys/freebsd/net/if_.d

diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 021149aabc7..f11c5fbfb0b 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-9471b25db9ed44d71e0e27956430c0c6a09c16db
+ceff48bf7db05503117f54fdc0cefcb89b711136
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/arrayop.d b/gcc/d/dmd/arrayop.d
index afe6054f4aa..af3875ea6c5 100644
--- a/gcc/d/dmd/arrayop.d
+++ b/gcc/d/dmd/arrayop.d
@@ -22,7 +22,7 @@ import dmd.dsymbol;
 import dmd.errors;
 import dmd.expression;
 import dmd.expressionsem;
-import dmd.func;
+import dmd.funcsem;
 import dmd.hdrgen;
 import dmd.id;
 import dmd.identifier;
diff --git a/gcc/d/dmd/ast_node.h b/gcc/d/dmd/ast_node.h
index a24218a86d0..db8608e7cdd 100644
--- a/gcc/d/dmd/ast_node.h
+++ b/gcc/d/dmd/ast_node.h
@@ -10,7 +10,7 @@
 
 #pragma once
 
-#include "root/object.h"
+#include "rootobject.h"
 
 class Visitor;
 
diff --git a/gcc/d/dmd/common/file.d b/gcc/d/dmd/common/file.d
index 8a284241fc2..80677f66ff8 100644
--- a/gcc/d/dmd/common/file.d
+++ b/gcc/d/dmd/common/file.d
@@ -16,24 +16,37 @@ module dmd.common.file;
 
 import core.stdc.errno : errno;
 import core.stdc.stdio : fprintf, remove, rename, stderr;
-import core.stdc.stdlib : exit;
-import core.stdc.string : strerror, strlen;
-import core.sys.windows.winbase;
-import core.sys.windows.winnt;
-import core.sys.posix.fcntl;
-import core.sys.posix.unistd;
+import core.stdc.stdlib;
+import core.stdc.string : strerror, strlen, memcpy;
 
 import dmd.common.smallbuffer;
 
-nothrow:
-
 version (Windows)
 {
+import core.sys.windows.winbase;
 import core.sys.windows.winnls : CP_ACP;
+import core.sys.windows.winnt;
+
+enum CodePage = CP_ACP; // assume filenames encoded in system default 
Windows ANSI code page
+enum invalidHandle = INVALID_HANDLE_VALUE;
+}
+else version (Posix)
+{
+

Re: [PATCH] testsuite, libphobos: Update link flags [PR112864].

2024-01-28 Thread Iain Buclaw
Excerpts from Iain Sandoe's message of Januar 28, 2024 4:03 pm:
> Tested on i686, x86_64, aarch64 Darwin, x86_64, aarch64 Linux,
> OK for trunk?
> thanks, 
> Iain
> 

Thanks Iain!

OK. Seems reasonable to me.

Iain.


Re: [PATCH] testsuite, GDC: Update link flags [PR112861].

2024-01-28 Thread Iain Buclaw
Excerpts from Iain Sandoe's message of Januar 28, 2024 4:02 pm:
> Tested on i686, x86_64, aarch64 Darwin, x86_64, aarch64 Linux,
> OK for trunk?
> thanks, 
> Iain
> 

OK.

Thanks again!

Iain.


Re: [PATCH v9 2/2] Add gcov MC/DC tests for GDC

2023-12-31 Thread Iain Buclaw
Excerpts from Jørgen Kvalsvik's message of Dezember 31, 2023 4:51 pm:
> This is a mostly straight port from the gcov-19.c tests from the C test
> suite. The only notable differences from C to D are that D flips the
> true/false outcomes for loop headers, and the D front end ties loop and
> ternary conditions to slightly different locus.
> 
> The test for >64 conditions warning is disabled as it either needs
> support from the testing framework or a something similar to #pragma GCC
> diagnostic push to not cause a test failure from detecting a warning.
> 

Thanks!

No problems with adding this to the gdc testsuite on my end.

Iain.


Re: [PATCH v3 1/3] LoongArch: Adjust D version strings.

2023-12-07 Thread Iain Buclaw
Hi,

Thanks for this.

Excerpts from Yang Yujie's message of Dezember 1, 2023 11:08 am:
> diff --git a/gcc/d/dmd/cond.d b/gcc/d/dmd/cond.d
> index 568b639e0b6..02af0cc9e29 100644
> --- a/gcc/d/dmd/cond.d
> +++ b/gcc/d/dmd/cond.d
> @@ -693,10 +693,10 @@ extern (C++) final class VersionCondition : DVCondition
>  case "LDC":
>  case "linux":
>  case "LittleEndian":
> -case "LoongArch32":
>  case "LoongArch64":
> -case "LoongArch_HardFloat":
> -case "LoongArch_SoftFloat":
> +case "LoongArch_F64":
> +case "LoongArch_F32":
> +case "LoongArch_SF":
>  case "MinGW":
>  case "MIPS32":
>  case "MIPS64":

Changes to this module should be submitted to github.com/dlang/dmd,
otherwise it'll get overwritten on the next "merge" with upstream.

What's the rationale for F64 and SF abbreviations?

Otherwise, looks reasonable.

Iain.


Re: [PATCH v3 2/3] libphobos: Update build scripts for LoongArch64.

2023-12-07 Thread Iain Buclaw
Excerpts from Yang Yujie's message of Dezember 1, 2023 11:08 am:
> libphobos/ChangeLog:
> 
>   * m4/druntime/cpu.m4: Support loongarch* targets.
>   * libdruntime/Makefile.am: Same.
>   * libdruntime/Makefile.in: Regenerate.
>   * configure: Regenerate.
> ---
>  libphobos/configure   | 21 ++-
>  libphobos/libdruntime/Makefile.am |  3 +
>  libphobos/libdruntime/Makefile.in | 98 +++
>  libphobos/m4/druntime/cpu.m4  |  5 ++
>  4 files changed, 87 insertions(+), 40 deletions(-)
> 
> diff --git a/libphobos/libdruntime/Makefile.am 
> b/libphobos/libdruntime/Makefile.am
> index 23205fd3301..ca43a0753c4 100644
> --- a/libphobos/libdruntime/Makefile.am
> +++ b/libphobos/libdruntime/Makefile.am
> @@ -83,6 +83,9 @@ endif
>  if DRUNTIME_CPU_ARM
>  DRUNTIME_SOURCES_CONFIGURED += config/arm/switchcontext.S
>  endif
> +if DRUNTIME_CPU_LOONGARCH
> +DRUNTIME_SOURCES_CONFIGURED += config/loongarch/switchcontext.S
> +endif
>  if DRUNTIME_CPU_MIPS
>  DRUNTIME_SOURCES_CONFIGURED += config/mips/switchcontext.S
>  endif

Just a nitpick, I'd thought the committing of switchcontext.S should
come before this. I have no strong opinion either way.

OK to commit.

Iain.


Re: [PATCH v3 3/3] libruntime: Add fiber context switch code for LoongArch.

2023-12-07 Thread Iain Buclaw
Excerpts from Yang Yujie's message of Dezember 1, 2023 11:08 am:
> libphobos/ChangeLog:
> 
>   * libdruntime/config/loongarch/switchcontext.S: New file.
> ---

OK.

Thanks,
Iain.


Re: [PATCH v2 3/3] libphobos: LoongArch hardware support.

2023-12-07 Thread Iain Buclaw
Excerpts from Yang Yujie's message of Dezember 1, 2023 8:46 am:
> libphobos/ChangeLog:
> 
>   * src/std/math/hardware.d: Implement FP control.
> ---
>  libphobos/src/std/math/hardware.d |  53 +++
> 
> diff --git a/libphobos/src/std/math/hardware.d 
> b/libphobos/src/std/math/hardware.d
> index cb6cb87845c..8d11459a8ac 100644
> --- a/libphobos/src/std/math/hardware.d
> +++ b/libphobos/src/std/math/hardware.d
> @@ -177,6 +177,20 @@ private:
>  return result;
>  }
>  }
> +else version (LoongArch_Any)
> +{
> +version (D_SoftFloat)
> +return 0;

Hi,

Changes to this module should go first to github.com/dlang/phobos.

I also notice that theses SoftFloat static conditions in all LoongArch
support code doesn't exist in upstream either.  Can a pull request be
raised to sort out the discrepancy?

Thanks,
Iain.


Re: [PATCH v3 2/2] libphobos: Update build scripts for LoongArch64.

2023-12-08 Thread Iain Buclaw
Excerpts from Yang Yujie's message of Dezember 8, 2023 11:09 am:
> libphobos/ChangeLog:
> 
>   * m4/druntime/cpu.m4: Support loongarch* targets.
>   * libdruntime/Makefile.am: Same.
>   * libdruntime/Makefile.in: Regenerate.
>   * configure: Regenerate.
> ---
>  libphobos/configure   | 21 ++-
>  libphobos/libdruntime/Makefile.am |  3 +
>  libphobos/libdruntime/Makefile.in | 98 +++
>  libphobos/m4/druntime/cpu.m4  |  5 ++
>  4 files changed, 87 insertions(+), 40 deletions(-)
> 

Both these patches by themselves are fine.

Thanks again!

Iain.


[committed] d: Merge upstream dmd, druntime 2bbf64907c, phobos b64bfbf91

2023-12-11 Thread Iain Buclaw
Hi,

This patch merges the D front-end and runtime library with upstream dmd
2bbf64907c, and the standard library with phobos b64bfbf91.

Synchronizing with the upstream release of v2.106.0.

D front-end changes:

- Import dmd v2.106.0.

D runtime changes:

- Import druntime v2.106.0.

Phobos changes:

- Import phobos v2.106.0.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* Make-lang.in (D_FRONTEND_OBJS): Rename d/common-string.o to
d/common-smallbuffer.o.
* dmd/MERGE: Merge upstream dmd 2bbf64907c.
* dmd/VERSION: Bump version to v2.106.0.
* modules.cc (layout_moduleinfo_fields): Update for new front-end
interface.
(layout_moduleinfo): Likewise.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 2bbf64907c.
* src/MERGE: Merge upstream phobos b64bfbf91.
---
 gcc/d/Make-lang.in|   2 +-
 gcc/d/dmd/MERGE   |   2 +-
 gcc/d/dmd/VERSION |   2 +-
 gcc/d/dmd/aggregate.d |  10 -
 gcc/d/dmd/aggregate.h |   1 -
 gcc/d/dmd/attrib.d|  67 --
 gcc/d/dmd/attrib.h|   9 -
 gcc/d/dmd/canthrow.d  |   2 +-
 gcc/d/dmd/common/README.md|   2 +-
 gcc/d/dmd/common/file.d   |  15 +-
 gcc/d/dmd/common/{string.d => smallbuffer.d}  |  49 ++--
 gcc/d/dmd/cparse.d|   8 +
 gcc/d/dmd/dcast.d |  12 +-
 gcc/d/dmd/denum.d |   7 -
 gcc/d/dmd/dimport.d   |  16 --
 gcc/d/dmd/dmodule.d   |  36 ++-
 gcc/d/dmd/dsymbol.d   | 172 --
 gcc/d/dmd/dsymbol.h   |   5 +-
 gcc/d/dmd/dsymbolsem.d| 214 +
 gcc/d/dmd/dtemplate.d |   7 +-
 gcc/d/dmd/enum.h  |   1 -
 gcc/d/dmd/escape.d|   2 +-
 gcc/d/dmd/expressionsem.d |   2 +-
 gcc/d/dmd/hdrgen.d|  27 +++
 gcc/d/dmd/import.h|   1 -
 gcc/d/dmd/initsem.d   |  20 +-
 gcc/d/dmd/module.h|   1 +
 gcc/d/dmd/nspace.d|  14 --
 gcc/d/dmd/nspace.h|   1 -
 gcc/d/dmd/parse.d |  12 +-
 gcc/d/dmd/root/file.d |   2 +-
 gcc/d/dmd/root/filename.d |   4 +-
 gcc/d/dmd/root/speller.d  |   2 +-
 gcc/d/dmd/root/string.d   |   2 +-
 gcc/d/dmd/typesem.d   |  58 +
 gcc/d/modules.cc  |   4 +-
 .../fail_compilation/misc_parser_err_cov1.d   |   2 +-
 gcc/testsuite/gdc.test/runnable/dbitfields.d  |  34 +++
 libphobos/libdruntime/MERGE   |   2 +-
 libphobos/libdruntime/core/cpuid.d|   7 +-
 libphobos/src/MERGE   |   2 +-
 libphobos/src/std/algorithm/searching.d   | 218 +++---
 libphobos/src/std/conv.d  |   5 +-
 libphobos/src/std/range/package.d |  24 +-
 libphobos/src/std/uni/package.d   |  12 +
 45 files changed, 579 insertions(+), 518 deletions(-)
 rename gcc/d/dmd/common/{string.d => smallbuffer.d} (82%)

diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
index b3007a96bd0..a0d4d7cbeb4 100644
--- a/gcc/d/Make-lang.in
+++ b/gcc/d/Make-lang.in
@@ -95,7 +95,7 @@ D_FRONTEND_OBJS = \
d/common-bitfields.o \
d/common-file.o \
d/common-outbuffer.o \
-   d/common-string.o \
+   d/common-smallbuffer.o \
d/compiler.o \
d/cond.o \
d/constfold.o \
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index aa0062c10eb..5edcee1c84d 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-ff57fec51558013b25cadb7e83da9f4675915d56
+2bbf64907cbbb483d003e0a8fcf8b502e4883799
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/VERSION b/gcc/d/dmd/VERSION
index 41fdc654b14..8c95cd04f80 100644
--- a/gcc/d/dmd/VERSION
+++ b/gcc/d/dmd/VERSION
@@ -1 +1 @@
-v2.106.0-rc.1
+v2.106.0
diff --git a/gcc/d/dmd/aggregate.d b/gcc/d/dmd/aggregate.d
index 307bb0171c4..352ca88f470 100644
--- a/gcc/d/dmd/aggregate.d
+++ b/gcc/d/dmd/aggregate.d
@@ -178,16 +178,6 @@ extern (C++) abstract class AggregateDeclaration : 
ScopeDsymbol
 return sc2;
 }
 
-override final void setScope(Scope* sc)
-{
-// Might need a scope to resolve forward references. The check for
-// semanticRun prevents unnecessary setting of _scope

Re: [committed] d: Merge upstream dmd, druntime 2bbf64907c, phobos b64bfbf91

2023-12-11 Thread Iain Buclaw
Excerpts from Iain Buclaw's message of Dezember 11, 2023 11:07 am:
> Hi,
> 
> This patch merges the D front-end and runtime library with upstream dmd
> 2bbf64907c, and the standard library with phobos b64bfbf91.
> 
> Synchronizing with the upstream release of v2.106.0.
> 

...

> diff --git a/gcc/d/dmd/canthrow.d b/gcc/d/dmd/canthrow.d
> index 67305922df6..5a608a9986d 100644
> --- a/gcc/d/dmd/canthrow.d
> +++ b/gcc/d/dmd/canthrow.d
> @@ -22,7 +22,6 @@ import dmd.declaration;
>  import dmd.dsymbol;
>  import dmd.errorsink;
>  import dmd.expression;
> -import dmd.expressionsem;
>  import dmd.func;
>  import dmd.globals;
>  import dmd.init;
> @@ -81,6 +80,7 @@ CT canThrow(Expression e, FuncDeclaration func, ErrorSink 
> eSink)
>  if (!f.isDtorDeclaration())
>  errorSupplementalInferredAttr(f, 10, false, 
> STC.nothrow_);
>  
> +import dmd.expressionsem : checkOverriddenDtor;
>  f.checkOverriddenDtor(null, e.loc, dd => 
> dd.type.toTypeFunction().isnothrow, "not nothrow");
>  }
>  else if (func)
> 

Hi Rainer,

This specific change that moves an import from toplevel to local should
fix that linker problem when using gdc-9 for bootstrapping.

Iain.


Re: [PATCH 2/3] Add generated .opt.urls files

2023-11-12 Thread Iain Buclaw
Excerpts from David Malcolm's message of November 10, 2023 10:42 pm:
> gcc/d/ChangeLog:
>   * lang.opt.urls: New file, autogenerated by
>   regenerate-opt-urls.py.
> ---
>  gcc/d/lang.opt.urls  |   95 +
>  create mode 100644 gcc/d/lang.opt.urls
> 

[abridged view of patch]

> diff --git a/gcc/d/lang.opt.urls b/gcc/d/lang.opt.urls
> new file mode 100644
> index ..57c14ecc459a
> --- /dev/null
> +++ b/gcc/d/lang.opt.urls
> @@ -0,0 +1,95 @@
> +; Autogenerated by regenerate-opt-urls.py from gcc/d/lang.opt and generated 
> HTML
> +
> +H
> +UrlSuffix(gcc/Preprocessor-Options.html#index-H)
> +
> +I
> +UrlSuffix(gcc/Directory-Options.html#index-I)
> +
> +M
> +UrlSuffix(gcc/Preprocessor-Options.html#index-M)
> +
> +MD
> +UrlSuffix(gcc/Preprocessor-Options.html#index-MD)
> +
> +MF
> +UrlSuffix(gcc/Preprocessor-Options.html#index-MF)
> +
> +MG
> +UrlSuffix(gcc/Preprocessor-Options.html#index-MG)
> +
> +MM
> +UrlSuffix(gcc/Preprocessor-Options.html#index-MM)
> +
> +MMD
> +UrlSuffix(gcc/Preprocessor-Options.html#index-MMD)
> +
> +MP
> +UrlSuffix(gcc/Preprocessor-Options.html#index-MP)
> +
> +MT
> +UrlSuffix(gcc/Preprocessor-Options.html#index-MT)
> +
> +MQ
> +UrlSuffix(gcc/Preprocessor-Options.html#index-MQ)
> +
> +Waddress
> +UrlSuffix(gcc/Warning-Options.html#index-Waddress)
> +
> +; skipping 'Wall' due to multiple URLs:
> +;   duplicate: 'gcc/Standard-Libraries.html#index-Wall-1'
> +;   duplicate: 'gcc/Warning-Options.html#index-Wall'
> +
> +Walloca
> +UrlSuffix(gcc/Warning-Options.html#index-Walloca)
> +
> +Walloca-larger-than=
> +UrlSuffix(gcc/Warning-Options.html#index-Walloca-larger-than_003d)
> +
> +Wbuiltin-declaration-mismatch
> +UrlSuffix(gcc/Warning-Options.html#index-Wbuiltin-declaration-mismatch)
> +
> +Wdeprecated
> +UrlSuffix(gcc/Warning-Options.html#index-Wdeprecated)
> +
> +Werror
> +UrlSuffix(gcc/Warning-Options.html#index-Werror)
> +
> +Wextra
> +UrlSuffix(gcc/Warning-Options.html#index-Wextra)
> +
> +Wunknown-pragmas
> +UrlSuffix(gcc/Warning-Options.html#index-Wno-unknown-pragmas)
> +
> +Wvarargs
> +UrlSuffix(gcc/Warning-Options.html#index-Wno-varargs)
> +
> +; skipping 'fbuiltin' due to multiple URLs:
> +;   duplicate: 'gcc/C-Dialect-Options.html#index-fbuiltin'
> +;   duplicate: 'gcc/Other-Builtins.html#index-fno-builtin-3'
> +;   duplicate: 'gcc/Warning-Options.html#index-fno-builtin-1'
> +
> +fexceptions
> +UrlSuffix(gcc/Code-Gen-Options.html#index-fexceptions)
> +
> +frtti
> +UrlSuffix(gcc/C_002b_002b-Dialect-Options.html#index-fno-rtti)
> +
> +imultilib
> +UrlSuffix(gcc/Directory-Options.html#index-imultilib)
> +
> +iprefix
> +UrlSuffix(gcc/Directory-Options.html#index-iprefix)
> +
> +isysroot
> +UrlSuffix(gcc/Directory-Options.html#index-isysroot)
> +
> +isystem
> +UrlSuffix(gcc/Directory-Options.html#index-isystem)
> +
> +nostdinc
> +UrlSuffix(gcc/Directory-Options.html#index-nostdinc)
> +
> +v
> +UrlSuffix(gcc/Overall-Options.html#index-v)
> +
> -- 
> 2.26.3
> 
> 

So I see this focuses on only adding URLs for common options, or options
that relate to C/C++ family, but may be handled by other front-ends too?

To pick out one, you have:

frtti
UrlSuffix(gcc/C_002b_002b-Dialect-Options.html#index-fno-rtti)

It looks like it could could alternatively be

frtti
UrlSuffix(gdc/Runtime-Options.html#index-frtti)

Or are other front-ends having URLs to their language-specific
documentation pages not supported for the same reason as why they can't
add self-documentation to their own options if another front-end
(typically C/C++) also makes claim to the option?

frtti
D 
; Documented in C


I'm OK with the D parts regardless of this observation.

Thanks,
Iain.


Re: [committed] d: Merge upstream dmd ff57fec515, druntime ff57fec515, phobos 17bafda79.

2023-11-22 Thread Iain Buclaw
Excerpts from Rainer Orth's message of November 21, 2023 4:59 pm:
> Hi Iain,
> 
>> This patch merges the D front-end and runtime library with upstream dmd
>> ff57fec515, and the standard library with phobos 17bafda79.
>>
>> Synchronizing with the upstream release candidate of v2.106.0.
>>
>> D front-end changes:
>>
>> - Import dmd v2.106.0-rc.1.
>> - New'ing multi-dimensional arrays are now are converted to a single
>>   template call `_d_newarraymTX'.
>>
>> D runtime changes:
>>
>> - Import druntime v2.106.0-rc.1.
>>
>> Phobos changes:
>>
>> - Import phobos v2.106.0-rc.1.
>>
>> Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
>> to mainline.
> 
> either this patch or the previous one broke D bootstrap with GCC 9.  On
> both i386-pc-solaris2.11 with gdc 9.4.0 and sparc-sun-solaris2.11 with
> gdc 9.3.0, stage 1 d21 fails to link with
> 
> Undefined   first referenced
>  symbol in file
> _D3dmd4root11stringtable34__T11StringValueTC3dmd5mtype4TypeZ11StringValue7lstringMFNaNbNiNjZPa
>  d/func.o
> _D3dmd4root11stringtable34__T11StringValueTC3dmd5mtype4TypeZ11StringValue8toDcharsMxFNaNbNiNjZPxa
>  d/func.o
> _D3dmd4root11stringtable34__T11StringValueTC3dmd5mtype4TypeZ11StringValue8toStringMxFNaNbNiNjZAxa
>  d/func.o
> ld: fatal: symbol referencing errors
> collect2: error: ld returned 1 exit status
> make[3]: *** [/vol/gcc/src/hg/master/local/gcc/d/Make-lang.in:236: d21] Error 
> 1
> 
> I'm now running bootstraps with gdc 11.1.0 instead, which seems to work:
> in both cases, stage 1 d21 did link.
> 
> If this is intentional, install.texi should be updated accordingly.
> 

Thanks Rainer,

I don't think this should happen if we can help it just yet.  I'll have
a look to see which specific upstream change might have caused it.

Iain.


Re: [committed] d: Merge upstream dmd ff57fec515, druntime ff57fec515, phobos 17bafda79.

2023-11-22 Thread Iain Buclaw
Excerpts from Rainer Orth's message of November 21, 2023 5:03 pm:
> Rainer Orth  writes:
> 
>> either this patch or the previous one broke D bootstrap with GCC 9.  On
>> both i386-pc-solaris2.11 with gdc 9.4.0 and sparc-sun-solaris2.11 with
>> gdc 9.3.0, stage 1 d21 fails to link with
>>
>> Undefined   first referenced
>>  symbol in file
>> _D3dmd4root11stringtable34__T11StringValueTC3dmd5mtype4TypeZ11StringValue7lstringMFNaNbNiNjZPa
>>  d/func.o
>> _D3dmd4root11stringtable34__T11StringValueTC3dmd5mtype4TypeZ11StringValue8toDcharsMxFNaNbNiNjZPxa
>>  d/func.o
>> _D3dmd4root11stringtable34__T11StringValueTC3dmd5mtype4TypeZ11StringValue8toStringMxFNaNbNiNjZAxa
>>  d/func.o
>> ld: fatal: symbol referencing errors
>> collect2: error: ld returned 1 exit status
>> make[3]: *** [/vol/gcc/src/hg/master/local/gcc/d/Make-lang.in:236: d21] 
>> Error 1
> 
> Same on i686-pc-linux-gnu, btw.
> 

Thanks, I've found the culprit.  There's been quite a few changes in the
import graph upstream.  This looks to have exposed some unfortunate
template emission bugs in older versions of the compiler that as you've
pointed out, work just fine with gdc-11.

I'm err'ing on the side of reverting the individual patches, though if I
get time later, maybe try a partial revert by restoring the old import
statements only.

Iain.


[committed] d: Merge upstream dmd, druntime 4574d1728d, phobos d7e79f024.

2023-09-23 Thread Iain Buclaw
Hi,

This patch merges the D front-end and run-time library with upstream dmd
4574d1728d, and standard library with phobos d7e79f024.

Updating the latest changes from the v2.105.0 release.

D front-end changes:

- Import dmd v2.105.0.
- Catch clause must take only `const' or mutable exceptions.
- Creating a `scope' class instance with a non-scope constructor
  is now `@system' only with `-fpreview=dip1000'.
- Global `const' variables can no longer be initialized from a
  non-shared static constructor

D runtime changes:

- Import druntime v2.105.0.

Phobos changes:

- Import phobos v2.105.0.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 4574d1728d.
* dmd/VERSION: Bump version to v2.105.0.
* d-diagnostic.cc (verror): Remove.
(verrorSupplemental): Remove.
(vwarning): Remove.
(vwarningSupplemental): Remove.
(vdeprecation): Remove.
(vdeprecationSupplemental): Remove.
(vmessage): Remove.
(vtip): Remove.
(verrorReport): New function.
(verrorReportSupplemental): New function.
* d-lang.cc (d_parse_file): Update for new front-end interface.
* decl.cc (d_mangle_decl): Update for new front-end interface.
* intrinsics.cc (maybe_set_intrinsic): Update for new front-end
interface.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 4574d1728d.
* src/MERGE: Merge upstream phobos d7e79f024.
---
 gcc/d/d-diagnostic.cc | 199 +---
 gcc/d/d-lang.cc   |   6 +-
 gcc/d/decl.cc |   2 +-
 gcc/d/dmd/MERGE   |   2 +-
 gcc/d/dmd/README.md   |   3 +-
 gcc/d/dmd/VERSION |   2 +-
 gcc/d/dmd/access.d|   1 -
 gcc/d/dmd/aggregate.d |   2 +-
 gcc/d/dmd/aliasthis.d |   3 +-
 gcc/d/dmd/arrayop.d   |  10 +-
 gcc/d/dmd/attrib.d|  47 ++-
 gcc/d/dmd/blockexit.d |   1 -
 gcc/d/dmd/canthrow.d  |   3 +-
 gcc/d/dmd/common/file.d   |   8 +
 gcc/d/dmd/common/outbuffer.d  |  12 +-
 gcc/d/dmd/common/string.d |   5 +-
 gcc/d/dmd/cond.d  |  16 +-
 gcc/d/dmd/constfold.d |   4 +-
 gcc/d/dmd/cppmangle.d |  18 +-
 gcc/d/dmd/ctfeexpr.d  |  24 +-
 gcc/d/dmd/ctorflow.d  |   8 +-
 gcc/d/dmd/dclass.d|   2 +-
 gcc/d/dmd/declaration.d   |  30 +-
 gcc/d/dmd/declaration.h   |   4 +-
 gcc/d/dmd/delegatize.d|   4 +-
 gcc/d/dmd/dinterpret.d|  17 +-
 gcc/d/dmd/dmangle.d   |  66 ++--
 gcc/d/dmd/dmodule.d   |   6 +-
 gcc/d/dmd/doc.d   |  99 +++---
 gcc/d/dmd/doc.h   |   3 +-
 gcc/d/dmd/dscope.d|  15 +-
 gcc/d/dmd/dsymbol.d   |  52 +--
 gcc/d/dmd/dsymbolsem.d|  30 +-
 gcc/d/dmd/dtemplate.d |  22 +-
 gcc/d/dmd/dtoh.d  |  23 +-
 gcc/d/dmd/dversion.d  |   8 +-
 gcc/d/dmd/errors.d| 180 ---
 gcc/d/dmd/errors.h|  20 +-
 gcc/d/dmd/errorsink.d |   6 +
 gcc/d/dmd/escape.d|   2 +-
 gcc/d/dmd/expression.d| 303 +-
 gcc/d/dmd/expression.h|   1 +
 gcc/d/dmd/expressionsem.d |  49 ++-
 gcc/d/dmd/foreachvar.d|   2 +-
 gcc/d/dmd/func.d  |  17 +-
 gcc/d/dmd/globals.d   |  18 +-
 gcc/d/dmd/globals.h   |   2 +-
 gcc/d/dmd/hdrgen.d|  16 +-
 gcc/d/dmd/id.d|   8 +-
 gcc/d/dmd/identifier.d|   6 +-
 gcc/d/dmd/imphint.d   |   2 +-
 gcc/d/dmd/init.d  |  14 +-
 gcc/d/dmd/intrange.d  |  50 +--
 gcc/d/dmd/json.d  |   2 +-
 gcc/d/dmd/lambdacomp.d|   2 +-
 gcc/d/dmd/lexer.d |   2 +-
 gcc/d/dmd/location.d  |   6 +-
 gcc/d/dmd/mangle.h|   8 +-
 gcc/d/dmd/mtype.d |  76 ++---
 gcc/d/dmd/mtype.

Re: [PATCH 1/1] gcc/d: add LoongArch64 support for D frontend

2023-09-24 Thread Iain Buclaw
Excerpts from liushuyu's message of September 24, 2023 1:21 am:
> 
> gcc/ChangeLog:
> 
>   * config.gcc: add loongarch-d.o to d_target_objs for LoongArch
>   architecture.
> 
> gcc/config/ChangeLog:
> 
>   * loongarch/loongarch-d.cc
>   (loongarch_d_target_versions): add interface function to define builtin
>   D versions for LoongArch architecture.
>   (loongarch_d_handle_target_float_abi): add interface function to define
>   builtin D traits for LoongArch architecture.
>   (loongarch_d_register_target_info): add interface function to register
>   loongarch_d_handle_target_float_abi function.
>   * loongarch/loongarch-d.h:
>   (loongarch_d_target_versions): add function prototype.
>   (loongarch_d_register_target_info): Likewise.
>   * loongarch/t-loongarch: add object target for loongarch-d.cc.
> 
> gcc/testsuite/ChangeLog:
> 
>   * gdc.test/fail_compilation/reserved_version.d: add reserved version
>   tests for LoongArch architecture and also updated expected output.
>   * gdc.test/fail_compilation/reserved_version_switch.d: Likewise.
> 
> libphobos/ChangeLog:
> 
>   * configure.tgt: enable libphobos for LoongArch architecture.
>   * configure: Regenerate.
>   * libdruntime/gcc/sections/elf.d: add TLS_DTV_OFFSET constant for
>   LoongArch64.
>   * libdruntime/gcc/unwind/generic.d: add __aligned__ constant for
>   LoongArch64.
>   * libdruntime/Makefile.in: Regenerate.
> 
> Signed-off-by: Zixing Liu 

Thanks, some comments below.

> diff --git a/gcc/config/loongarch/loongarch-d.cc 
> b/gcc/config/loongarch/loongarch-d.cc
> new file mode 100644
> index 000..d7875079212
> --- /dev/null
> +++ b/gcc/config/loongarch/loongarch-d.cc
> @@ -0,0 +1,82 @@
> +/* Subroutines for the D front end on the LoongArch architecture.
> +   Copyright (C) 2017-2023 Free Software Foundation, Inc.

Copyright years start from the year the source file was introduced.

> +
> +GCC is free software; you can redistribute it and/or modify
> +it under the terms of the GNU General Public License as published by
> +the Free Software Foundation; either version 3, or (at your option)
> +any later version.
> +
> +GCC is distributed in the hope that it will be useful,
> +but WITHOUT ANY WARRANTY; without even the implied warranty of
> +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +GNU General Public License for more details.
> +
> +You should have received a copy of the GNU General Public License
> +along with GCC; see the file COPYING3.  If not see
> +.  */
> +
> +#define IN_TARGET_CODE 1
> +
> +#include "config.h"
> +#include "system.h"
> +#include "coretypes.h"
> +#include "tm_d.h"
> +#include "d/d-target.h"
> +#include "d/d-target-def.h"
> +
> +/* Implement TARGET_D_CPU_VERSIONS for LoongArch targets.  */
> +
> +void
> +loongarch_d_target_versions (void)
> +{
> +  if (TARGET_64BIT)
> +d_add_builtin_version ("LoongArch64");
> +  else
> +d_add_builtin_version ("LoongArch32");
> +
> +  if (TARGET_ABI_LP64)
> +d_add_builtin_version ("D_LP64");

D_LP64 is already predefined by d/d-builtins.cc if POINTER_SIZE == 64,
and it should not be confused with any LP64 ABI model.  I haven't
checked what happens if you predefine the same version twice.

> +  else
> +d_add_builtin_version ("D_LP32");

D_LP32 is not a standardized predefined version condition as far as I'm
aware. Maybe these should be LoongArch_LP64 and LoongArch_LP32 instead.

> +
> +  if (TARGET_HARD_FLOAT_ABI)
> +{
> +  d_add_builtin_version ("LoongArch_HardFloat");
> +  d_add_builtin_version ("D_HardFloat");
> +}
> +  else if (TARGET_SOFT_FLOAT_ABI)
> +{
> +  d_add_builtin_version ("LoongArch_SoftFloat");
> +  d_add_builtin_version ("D_SoftFloat");
> +}
> +}
> +
> diff --git a/gcc/testsuite/gdc.test/fail_compilation/reserved_version.d 
> b/gcc/testsuite/gdc.test/fail_compilation/reserved_version.d
> index f7a554ce729..b00b3453d85 100644
> --- a/gcc/testsuite/gdc.test/fail_compilation/reserved_version.d
> +++ b/gcc/testsuite/gdc.test/fail_compilation/reserved_version.d

These tests would be added anyway as part of merging the upstream DMD
mainline, but otherwise I wouldn't object to update them here.

Regards,
Iain.


Re: [PATCH 02/52] d: Replace use of LONG_DOUBLE_TYPE_SIZE

2024-06-03 Thread Iain Buclaw
Excerpts from Kewen Lin's message of Juni 3, 2024 5:00 am:
> Joseph pointed out "floating types should have their mode,
> not a poorly defined precision value" in the discussion[1],
> as he and Richi suggested, the existing macros
> {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE will be replaced with a
> hook mode_for_floating_type.  To be prepared for that, this
> patch is to replace use of LONG_DOUBLE_TYPE_SIZE in d with
> TYPE_PRECISION of long_double_type_node.
> 
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
> 

Thanks, one question though: Is TYPE_PRECISION really equivalent to
LONG_DOUBLE_TYPE_SIZE?

Unless LONG_DOUBLE_TYPE_SIZE was poorly named to begin with, I'd assume
the answer to be "no".

i.e: TYPE_PRECISION = 80, but LONG_DOUBLE_TYPE_SIZE = 96 or 128.

Iain.


Re: [PATCH 02/52] d: Replace use of LONG_DOUBLE_TYPE_SIZE

2024-06-03 Thread Iain Buclaw
Excerpts from Kewen.Lin's message of Juni 3, 2024 10:57 am:
> Hi Iain,
> 
> on 2024/6/3 16:40, Iain Buclaw wrote:
>> Excerpts from Kewen Lin's message of Juni 3, 2024 5:00 am:
>>> Joseph pointed out "floating types should have their mode,
>>> not a poorly defined precision value" in the discussion[1],
>>> as he and Richi suggested, the existing macros
>>> {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE will be replaced with a
>>> hook mode_for_floating_type.  To be prepared for that, this
>>> patch is to replace use of LONG_DOUBLE_TYPE_SIZE in d with
>>> TYPE_PRECISION of long_double_type_node.
>>>
>>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>>
>> 
>> Thanks, one question though: Is TYPE_PRECISION really equivalent to
>> LONG_DOUBLE_TYPE_SIZE?
> 
> Yes, it's guaranteed by the code in build_common_tree_nodes:
> 
>   long_double_type_node = make_node (REAL_TYPE);
>   TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
>   layout_type (long_double_type_node);
> 
> , the macro LONG_DOUBLE_TYPE_SIZE is assigned to TYPE_PRECISION of
> long_double_type_node, layout_type will only pick up one mode as
> the given precision and won't change it.
> 
>> 
>> Unless LONG_DOUBLE_TYPE_SIZE was poorly named to begin with, I'd assume
>> the answer to be "no".
> 
> I'm afraid it's poorly named before.
> 

Thanks for confirming Kewen.

I suspect then that this code is incorrectly using this macro, and it
should instead be using:

int_size_in_bytes(long_double_type_node)

as any padding should be considered as part of the overall type size for
the purpose that this field serves in the D part of the front-end.

Are you able to update the patch this way instead? Otherwise I'm happy
to push the change instead.

Thanks again,
Iain.


Re: [PATCH 02/52 v2] d: Replace use of LONG_DOUBLE_TYPE_SIZE

2024-06-04 Thread Iain Buclaw
Excerpts from Kewen.Lin's message of Juni 4, 2024 5:17 am:
> Hi Iain,
> 
> on 2024/6/3 22:39, Iain Buclaw wrote:
>> Excerpts from Kewen.Lin's message of Juni 3, 2024 10:57 am:
>>> Hi Iain,
>>>
>>> on 2024/6/3 16:40, Iain Buclaw wrote:
>>>> Excerpts from Kewen Lin's message of Juni 3, 2024 5:00 am:
>>>>> Joseph pointed out "floating types should have their mode,
>>>>> not a poorly defined precision value" in the discussion[1],
>>>>> as he and Richi suggested, the existing macros
>>>>> {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE will be replaced with a
>>>>> hook mode_for_floating_type.  To be prepared for that, this
>>>>> patch is to replace use of LONG_DOUBLE_TYPE_SIZE in d with
>>>>> TYPE_PRECISION of long_double_type_node.
>>>>>
>>>>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>>>>
>>>>
>>>> Thanks, one question though: Is TYPE_PRECISION really equivalent to
>>>> LONG_DOUBLE_TYPE_SIZE?
>>>
>>> Yes, it's guaranteed by the code in build_common_tree_nodes:
>>>
>>>   long_double_type_node = make_node (REAL_TYPE);
>>>   TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
>>>   layout_type (long_double_type_node);
>>>
>>> , the macro LONG_DOUBLE_TYPE_SIZE is assigned to TYPE_PRECISION of
>>> long_double_type_node, layout_type will only pick up one mode as
>>> the given precision and won't change it.
>>>
>>>>
>>>> Unless LONG_DOUBLE_TYPE_SIZE was poorly named to begin with, I'd assume
>>>> the answer to be "no".
>>>
>>> I'm afraid it's poorly named before.
>>>
>> 
>> Thanks for confirming Kewen.
>> 
>> I suspect then that this code is incorrectly using this macro, and it
>> should instead be using:
>> 
>> int_size_in_bytes(long_double_type_node)
>> 
>> as any padding should be considered as part of the overall type size for
>> the purpose that this field serves in the D part of the front-end.
> 
> Got it, thanks for the explanation and suggestion.
> 
>> 
>> Are you able to update the patch this way instead? Otherwise I'm happy
>> to push the change instead.
> 
> Sure, updated as below:
> 

Thanks!

This is OK to apply any time.

Iain.


[committed] d: Fix ICE in build_deref, at d/d-codegen.cc:1650 [PR111650]

2024-04-19 Thread Iain Buclaw
Hi,

This regression in the D front-end was found to be caused by in some
cases the hidden closure parameter type being generated too early for
nested functions.  Better to update the type after the local
closure/frame type has been completed.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-m64,
committed to mainline, and backporting to releases/gcc-13.

Regards,
Iain.

---
PR d/111650

gcc/d/ChangeLog:

* decl.cc (get_fndecl_arguments): Move generation of frame type to ...
(DeclVisitor::visit (FuncDeclaration *)): ... here, after the call to
build_closure.

gcc/testsuite/ChangeLog:

* gdc.dg/pr111650.d: New test.
---
 gcc/d/decl.cc   | 20 ++--
 gcc/testsuite/gdc.dg/pr111650.d | 21 +
 2 files changed, 31 insertions(+), 10 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/pr111650.d

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 3b7627d3dfa..0a87c85ae2e 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -163,16 +163,6 @@ get_fndecl_arguments (FuncDeclaration *decl)
  tree parm_decl = get_symbol_decl (decl->vthis);
  DECL_ARTIFICIAL (parm_decl) = 1;
  TREE_READONLY (parm_decl) = 1;
-
- if (decl->vthis->type == Type::tvoidptr)
-   {
- /* Replace generic pointer with back-end closure type
-(this wins for gdb).  */
- tree frame_type = FRAMEINFO_TYPE (get_frameinfo (decl));
- gcc_assert (frame_type != NULL_TREE);
- TREE_TYPE (parm_decl) = build_pointer_type (frame_type);
-   }
-
  param_list = chainon (param_list, parm_decl);
}
 
@@ -1072,6 +1062,16 @@ public:
 /* May change cfun->static_chain.  */
 build_closure (d);
 
+/* Replace generic pointer with back-end closure type
+   (this wins for gdb).  */
+if (d->vthis && d->vthis->type == Type::tvoidptr)
+  {
+   tree frame_type = FRAMEINFO_TYPE (get_frameinfo (d));
+   gcc_assert (frame_type != NULL_TREE);
+   tree parm_decl = get_symbol_decl (d->vthis);
+   TREE_TYPE (parm_decl) = build_pointer_type (frame_type);
+  }
+
 if (d->vresult)
   declare_local_var (d->vresult);
 
diff --git a/gcc/testsuite/gdc.dg/pr111650.d b/gcc/testsuite/gdc.dg/pr111650.d
new file mode 100644
index 000..4298a76d38f
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr111650.d
@@ -0,0 +1,21 @@
+// { dg-do compile }
+ref V require(K, V)(ref V[K] aa, K key, lazy V value);
+
+struct Root
+{
+ulong[3] f;
+}
+
+Root[ulong] roots;
+
+Root getRoot(int fd, ulong rootID)
+{
+return roots.require(rootID,
+{
+Root result;
+inoLookup(fd, () => result);
+return result;
+}());
+}
+
+void inoLookup(int, scope Root delegate()) { }
-- 
2.40.1



Re: [PATCH, gdc] - Merging gdc (GNU D Compiler) into gcc

2012-10-04 Thread Iain Buclaw
I would like to get a bump on this.

It's been a while, and there have been quite a number of changes since
the initial post that address many of the issues raised.  Rather than
reposting patches, someone mentioned attaching changelog, well, here
it is.

Repository is still located here: https://github.com/D-Programming-GDC/GDC

Would it be possible to have a re-newed review?  I'm still keen on
pushing this, however I'm not certain of the right plan of execution.
:-)


Thanks,
-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


ChangeLog.gz
Description: GNU Zip compressed data


Re: [PATCH, gdc] - Merging gdc (GNU D Compiler) into gcc

2012-10-04 Thread Iain Buclaw
On 4 October 2012 16:51, Mike Stump  wrote:
> On Oct 4, 2012, at 6:06 AM, Iain Buclaw  wrote:
>> I would like to get a bump on this.
>>
>> It's been a while, and there have been quite a number of changes since
>> the initial post that address many of the issues raised.  Rather than
>> reposting patches, someone mentioned attaching changelog, well, here
>> it is.
>>
>> Repository is still located here: https://github.com/D-Programming-GDC/GDC
>>
>> Would it be possible to have a re-newed review?
>
> You don't ask, you post.  If you have independent patches to the rest of gcc 
> that improve it, I'd suggest posting those as separate patches and getting 
> those in.  This give you a base onto which to slot in the front-end.

Hi Mike,

The only patches to gcc proper are documentation-related and adding
the D frontend / libphobos to configure and make files.  I would have
thought that these would typically only be included with the actual
front-end?


Regards
-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


Re: [PATCH, gdc] - Merging gdc (GNU D Compiler) into gcc

2012-10-05 Thread Iain Buclaw
On 5 October 2012 01:06, Joseph S. Myers  wrote:
> On Thu, 4 Oct 2012, Iain Buclaw wrote:
>
>> The only patches to gcc proper are documentation-related and adding
>> the D frontend / libphobos to configure and make files.  I would have
>> thought that these would typically only be included with the actual
>> front-end?
>
> Looking back at my previous review comments, I suggested that you might
> need to split up c-common.[ch] so that certain parts of attribute handling
> could be shared with D, because duplicate code copied from elsewhere in
> GCC was not an appropriate implementation approach.  Have you then
> eliminated the duplicate code in some other way that does not involve
> splitting up those files so code can be shared?
>

Ah, no; thanks for reminding me of this.

The code duplicated from c-common.[ch] are the handlers for C
__attributes__,  however gdc doesn't use all of them because some just
don't have a fitting place eg: gnu_inline, artificial.

Would the best approach be to move all handle_* functions and any
helper functions into a new source file that can be shared between
frontends, and define two new frontend hooks,
LANG_HOOK_ATTRIBUTE_TABLE and LANG_HOOK_FORMAT_ATTRIBUTE_TABLE ?


Regards
-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


Re: [PATCH, gdc] - Merging gdc (GNU D Compiler) into gcc

2012-10-14 Thread Iain Buclaw
On 5 October 2012 11:35, Richard Guenther  wrote:
> On Fri, Oct 5, 2012 at 12:07 PM, Iain Buclaw  wrote:
>> On 5 October 2012 01:06, Joseph S. Myers  wrote:
>>> On Thu, 4 Oct 2012, Iain Buclaw wrote:
>>>
>>>> The only patches to gcc proper are documentation-related and adding
>>>> the D frontend / libphobos to configure and make files.  I would have
>>>> thought that these would typically only be included with the actual
>>>> front-end?
>>>
>>> Looking back at my previous review comments, I suggested that you might
>>> need to split up c-common.[ch] so that certain parts of attribute handling
>>> could be shared with D, because duplicate code copied from elsewhere in
>>> GCC was not an appropriate implementation approach.  Have you then
>>> eliminated the duplicate code in some other way that does not involve
>>> splitting up those files so code can be shared?
>>>
>>
>> Ah, no; thanks for reminding me of this.
>>
>> The code duplicated from c-common.[ch] are the handlers for C
>> __attributes__,  however gdc doesn't use all of them because some just
>> don't have a fitting place eg: gnu_inline, artificial.
>>
>> Would the best approach be to move all handle_* functions and any
>> helper functions into a new source file that can be shared between
>> frontends, and define two new frontend hooks,
>> LANG_HOOK_ATTRIBUTE_TABLE and LANG_HOOK_FORMAT_ATTRIBUTE_TABLE ?
>
> Btw, the LTO frontend also has most of the stuff duplicated ... (see
> lto/lto-lang.c).
> Not sure why ...
>
> Richard.
>

Looks like LTO's frontend has the relevant attributes duplicated in
order to support the attributes used for GCC builtins (const, pure,
nothrow, transaction_pure, etc...).  Probably only these handlers that
could move to a common frontend location, and keep the rest as part of
c-family.


Regards,
-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


[PATCH, 69217]: [6 Regression] ICE at var-tracking.c:5038 Segmentation fault

2016-01-23 Thread Iain Buclaw
Hi,

This fixes the regression seen from a change at revision 231897.

Unfortunately I don't have any tests as it was noticed in my frontend
(D).  And equivalent C/C++ doesn't trigger because:

- C set the mode of empty struct types as BLKmode.
- C++ lowered passing around empty struct types as CONSTRUCTOR expressions.

Perhaps other front-ends could trigger this, but I would not know how
to write an equivalent test for them.  In any case, I hope this is an
obvious patch.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69217

Regards,
Iain.
Author: Iain Buclaw 
Date:   Sat Jan 23 13:42:51 2016 +0100

	PR rtl-optimization/69217
	* var-tracking.c (tracked_record_parameter_p): Don't segfault if there
	are no TYPE_FIELDS set for the record type.

diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 86183b3..de3a80b 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -5128,7 +5128,8 @@ tracked_record_parameter_p (tree t)
   if (TREE_CODE (type) != RECORD_TYPE)
 return false;
 
-  if (DECL_CHAIN (TYPE_FIELDS (type)) == NULL_TREE)
+  if (TYPE_FIELDS (type) == NULL_TREE
+  || DECL_CHAIN (TYPE_FIELDS (type)) == NULL_TREE)
 return false;
 
   return true;


[PATCH] jit: Fix missing references to pthread in jit-playback.c

2016-01-23 Thread Iain Buclaw
Hi,

I noticed when building from 2016-01-17 snapshot that the JIT frontend
failed to build.

---
jit-playback.c:2075:36: error: ‘PTHREAD_MUTEX_INITIALIZER’ was not
declared in this scope
jit-playback.c: In member function ‘void
gcc::jit::playback::context::acquire_mutex()’:
jit-playback.c:2086:33: error: ‘pthread_mutex_lock’ was not declared
in this scope
jit-playback.c: In member function ‘void
gcc::jit::playback::context::release_mutex()’:
jit-playback.c:2100:35: error: ‘pthread_mutex_unlock’ was not declared
in this scope
---

I'm not sure if this is something environmental on my side, or some
reorder/removals were done in the gcc headers included by the JIT
frontend, however this was needed in order to continue.

Regards
Iain.
Author: Iain Buclaw 
Date:   Sat Jan 23 18:59:44 2016 +0100

gcc/jit/ChangeLog:
	* jit-playback.c: Include pthread.h.

diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
index d150ec1..579230d 100644
--- a/gcc/jit/jit-playback.c
+++ b/gcc/jit/jit-playback.c
@@ -38,6 +38,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "fold-const.h"
 #include "gcc.h"
 
+#include 
+
 #include "jit-playback.h"
 #include "jit-result.h"
 #include "jit-builtins.h"


Re: [PATCH] jit: Fix missing references to pthread in jit-playback.c

2016-01-26 Thread Iain Buclaw
On 26 January 2016 at 01:33, David Malcolm  wrote:
>
> On Sat, 2016-01-23 at 19:08 +0100, Iain Buclaw wrote:
> > Hi,
> >
> > I noticed when building from 2016-01-17 snapshot that the JIT frontend
> > failed to build.
> >
> > ---
> > jit-playback.c:2075:36: error: ‘PTHREAD_MUTEX_INITIALIZER’ was not
> > declared in this scope
> > jit-playback.c: In member function ‘void
> > gcc::jit::playback::context::acquire_mutex()’:
> > jit-playback.c:2086:33: error: ‘pthread_mutex_lock’ was not declared
> > in this scope
> > jit-playback.c: In member function ‘void
> > gcc::jit::playback::context::release_mutex()’:
> > jit-playback.c:2100:35: error: ‘pthread_mutex_unlock’ was not declared
> > in this scope
> > ---
> >
> > I'm not sure if this is something environmental on my side, or some
> > reorder/removals were done in the gcc headers included by the JIT
> > frontend, however this was needed in order to continue.
>
> Thanks.  Doko just reported the same issue, and I now see it (with
> r232813) so this isn't just at your end.
>
> OK for trunk.
>
> Dave
>

Thanks, I've committed this in.

Iain.


[PATCH 1/3] [D] libiberty: Correctly decode function pointer types.

2016-01-26 Thread Iain Buclaw
Hi,

This patch series ultimately supports recent support for
extern(Objective-C) functions.  However this simple addition exposed
two nasty bugs in the process.

This addresses demangling function types.  In real symbols, function
types are only ever seen following the pointer type symbol 'P'.  So
this is reflected in both code and tests.

Iain.
---
libiberty/

	* d-demangle.c (dlang_type): Handle function types only in the context
	of seeing a pointer type symbol.
	* testsuite/d-demangle-expected: Update function pointer tests.
 
difVf --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 3d7ccf6..9c4d459 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -1,5 +1,5 @@
 /* Demangler for the D programming language
-   Copyright 2014, 2015 Free Software Foundation, Inc.
+   Copyright 2014, 2015, 2016 Free Software Foundation, Inc.
Written by Iain Buclaw (ibuc...@gdcproject.org)
 
 This file is part of the libiberty library.
@@ -533,6 +533,15 @@ dlang_type (string *decl, const char *mangled)
 }
 case 'P': /* pointer (T*) */
   mangled++;
+  /* Function pointer types don't include the trailing asterisk.  */
+  switch (*mangled)
+	{
+	case 'F': case 'U': case 'W':
+	case 'V': case 'R':
+	  mangled = dlang_function_type (decl, mangled);
+	  string_append (decl, "function");
+	  return mangled;
+	}
   mangled = dlang_type (decl, mangled);
   string_append (decl, "*");
   return mangled;
@@ -564,13 +573,6 @@ dlang_type (string *decl, const char *mangled)
   mangled++;
   return dlang_parse_tuple (decl, mangled);
 
-/* Function types */
-case 'F': case 'U': case 'W':
-case 'V': case 'R':
-  mangled = dlang_function_type (decl, mangled);
-  string_append (decl, "function");
-  return mangled;
-
 /* Basic types */
 case 'n':
   mangled++;
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index 2b1cc4f..11785f2 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -390,23 +390,23 @@ _D8demangle4testFDRZaZv
 demangle.test(extern(C++) char() delegate)
 #
 --format=dlang
-_D8demangle4testFFZaZv
+_D8demangle4testFPFZaZv
 demangle.test(char() function)
 #
 --format=dlang
-_D8demangle4testFUZaZv
+_D8demangle4testFPUZaZv
 demangle.test(extern(C) char() function)
 #
 --format=dlang
-_D8demangle4testFWZaZv
+_D8demangle4testFPWZaZv
 demangle.test(extern(Windows) char() function)
 #
 --format=dlang
-_D8demangle4testFVZaZv
+_D8demangle4testFPVZaZv
 demangle.test(extern(Pascal) char() function)
 #
 --format=dlang
-_D8demangle4testFRZaZv
+_D8demangle4testFPRZaZv
 demangle.test(extern(C++) char() function)
 #
 --format=dlang
@@ -466,59 +466,59 @@ _D8demangle4testFNjNkDFNjZaZv
 demangle.test(return char() return delegate)
 #
 --format=dlang
-_D8demangle4testFFNaZaZv
+_D8demangle4testFPFNaZaZv
 demangle.test(char() pure function)
 #
 --format=dlang
-_D8demangle4testFFNbZaZv
+_D8demangle4testFPFNbZaZv
 demangle.test(char() nothrow function)
 #
 --format=dlang
-_D8demangle4testFFNcZaZv
+_D8demangle4testFPFNcZaZv
 demangle.test(char() ref function)
 #
 --format=dlang
-_D8demangle4testFFNdZaZv
+_D8demangle4testFPFNdZaZv
 demangle.test(char() @property function)
 #
 --format=dlang
-_D8demangle4testFFNeZaZv
+_D8demangle4testFPFNeZaZv
 demangle.test(char() @trusted function)
 #
 --format=dlang
-_D8demangle4testFFNfZaZv
+_D8demangle4testFPFNfZaZv
 demangle.test(char() @safe function)
 #
 --format=dlang
-_D8demangle4testFFNiZaZv
+_D8demangle4testFPFNiZaZv
 demangle.test(char() @nogc function)
 #
 --format=dlang
-_D8demangle4testFFNaNbZaZv
+_D8demangle4testFPFNaNbZaZv
 demangle.test(char() pure nothrow function)
 #
 --format=dlang
-_D8demangle4testFFNbNaZaZv
+_D8demangle4testFPFNbNaZaZv
 demangle.test(char() nothrow pure function)
 #
 --format=dlang
-_D8demangle4testFFNdNfNaZaZv
+_D8demangle4testFPFNdNfNaZaZv
 demangle.test(char() @property @safe pure function)
 #
 --format=dlang
-_D8demangle4testFNjFZaZv
+_D8demangle4testFNjPFZaZv
 demangle.test(char() function)
 #
 --format=dlang
-_D8demangle4testFNkFZaZv
+_D8demangle4testFNkPFZaZv
 demangle.test(return char() function)
 #
 --format=dlang
-_D8demangle4testFFNjZaZv
+_D8demangle4testFPFNjZaZv
 demangle.test(char() return function)
 #
 --format=dlang
-_D8demangle4testFNjNkFNjZaZv
+_D8demangle4testFNjNkPFNjZaZv
 demangle.test(return char() return function)
 #
 --format=dlang
@@ -989,7 +989,7 @@ object.TypeInfo_Array.argTypes(out TypeInfo, out TypeInfo)
 #
 --format=dlang
 _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv
-rt.dmain2._d_run_main(int, char**, extern(C) int(char[][]) function*).tryExec(scope void() delegate)
+rt.dmain2._d_run_main(int, char**, extern(C) int(char[][]) function).tryExec(scope void() delegate)
 #
 --format=dlang
 _D6object9Exception6__ctorMFNaNbNfAyaAyamC6object9ThrowableZC9Exception


[PATCH 2/3] [D] libiberty: Fix demangling of D-style variadic functions

2016-01-26 Thread Iain Buclaw
This one fixes support for D-style variadic functions, specifically
where non-variadic parameters can be omitted entirely.

Iain
---
libiberty/

 2016-01-26  Iain Buclaw  
 
	* d-demangle.c (dlang_function_args): Append ',' for variadic functions
	only if parameters were seen before the elipsis symbol.
	* testsuite/d-demangle-expected: Add coverage test for parameter-less
	variadic functions.

diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 9c4d459..9e5a8043 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -399,7 +399,9 @@ dlang_function_args (string *decl, const char *mangled)
 	  return mangled;
 	case 'Y': /* (variadic T t, ...) style.  */
 	  mangled++;
-	  string_append (decl, ", ...");
+	  if (n != 0)
+	string_append (decl, ", ");
+	  string_append (decl, "...");
 	  return mangled;
 	case 'Z': /* Normal function.  */
 	  mangled++;
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index 11785f2..8f0b167 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -342,6 +342,10 @@ _D8demangle4testFaaYv
 demangle.test(char, char, ...)
 #
 --format=dlang
+_D8demangle4testFYv
+demangle.test(...)
+#
+--format=dlang
 _D8demangle4testFaaZv
 demangle.test(char, char)
 #


[PATCH 3/3] [D] libiberty: Handle the new extern(Objective-C) calling convention

2016-01-26 Thread Iain Buclaw
Finally, recognizing the extern(Objective-C) symbol 'Y'.

Iain.
---
libiberty/

 2016-01-26  Iain Buclaw  
 
	* d-demangle.c (dlang_call_convention): Handle extern Objective-C
	function calling convention.
	(dlang_call_convention_p): Likewise.
	(dlang_type): Likewise.
	* testsuite/d-demangle-expected: Add coverage tests.

diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 9e5a8043..4ad90a6 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -223,6 +223,10 @@ dlang_call_convention (string *decl, const char *mangled)
   mangled++;
   string_append (decl, "extern(C++) ");
   break;
+case 'Y': /* (Objective-C) */
+  mangled++;
+  string_append (decl, "extern(Objective-C) ");
+  break;
 default:
   return NULL;
 }
@@ -539,7 +543,7 @@ dlang_type (string *decl, const char *mangled)
   switch (*mangled)
 	{
 	case 'F': case 'U': case 'W':
-	case 'V': case 'R':
+	case 'V': case 'R': case 'Y':
 	  mangled = dlang_function_type (decl, mangled);
 	  string_append (decl, "function");
 	  return mangled;
@@ -1338,7 +1342,7 @@ dlang_call_convention_p (const char *mangled)
   switch (*mangled)
 {
 case 'F': case 'U': case 'V':
-case 'W': case 'R':
+case 'W': case 'R': case 'Y':
   return 1;
 
 default:
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index 8f0b167..04d39f4 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -394,6 +394,10 @@ _D8demangle4testFDRZaZv
 demangle.test(extern(C++) char() delegate)
 #
 --format=dlang
+_D8demangle4testFDYZaZv
+demangle.test(extern(Objective-C) char() delegate)
+#
+--format=dlang
 _D8demangle4testFPFZaZv
 demangle.test(char() function)
 #
@@ -414,6 +418,10 @@ _D8demangle4testFPRZaZv
 demangle.test(extern(C++) char() function)
 #
 --format=dlang
+_D8demangle4testFPYZaZv
+demangle.test(extern(Objective-C) char() function)
+#
+--format=dlang
 _D8demangle4testFDFNaZaZv
 demangle.test(char() pure delegate)
 #


Re: [PATCH 1/3] [D] libiberty: Correctly decode function pointer types.

2016-01-26 Thread Iain Buclaw
On 27 January 2016 at 01:49, Ian Lance Taylor  wrote:
> On Tue, Jan 26, 2016 at 4:30 PM, Iain Buclaw  wrote:
>>
>> This patch series ultimately supports recent support for
>> extern(Objective-C) functions.  However this simple addition exposed
>> two nasty bugs in the process.
>>
>> This addresses demangling function types.  In real symbols, function
>> types are only ever seen following the pointer type symbol 'P'.  So
>> this is reflected in both code and tests.
>
> This is OK.
>
> Thanks.
>
> Ian

That was a very prompt response!  Committing to trunk now...

Regards
Iain.


Re: [PATCH] Use DW_LANG_D for D

2013-12-04 Thread Iain Buclaw
On 3 December 2013 19:42, Cary Coutant  wrote:
>> This patches gen_compile_unit_die to use the DW_LANG_D DWARF language
>> code for D.  Is in relation to some other D language fixes that are
>> going to be submitted to gdb.
>
> Is this for a private front end? I'm not aware of any front ends that
> set the language name to "GNU D".
>
> Since it's so trivial, though, I have no problem with this patch for
> Stage 3 -- if you do have a separate front end that sets that language
> string, then it's arguably a bug fix. If this patch is preparation for
> more substantial changes to the GCC tree, however, I suspect you're
> going to need to wait for Stage 1 to reopen anyway.
>
> So, if this is a standalone patch, it's OK, but you also need a ChangeLog 
> entry.
>
> -cary

The frontend isn't private, but is currently external to GCC.

I've had plans to get the frontend merged for some time now.  And was
adviced last time I submitted the code for review to send patches that
can be merged into GCC prior to re-submitting the frontend - which as
you have already said will have to wait for Stage 1 to reopen.

Will make a changelog entry for the patch.

Regards
Iain.


[PATCH/libiberty] Remove use of strtod in libiberty/d-demangle.c

2015-08-04 Thread Iain Buclaw
Fixes PR 18669 raised against gdb/binutils.

https://sourceware.org/bugzilla/show_bug.cgi?id=18669

While it is possible to roll our own strtod that handles hexadecimal
to float conversion, I'm no longer interested taking time out to
implement or maintain such a thing.  So the next obvious thing to do
is nothing, which is what I've settled for.

Regards
Iain.
2015-08-04  Iain Buclaw  

	* d-demangle.c (dlang_parse_real): Remove call to strtod.
	(strtod): Remove declaration.
	* testsuite/d-demangle-expected: Update float and complex literal
	tests to check correct hexadecimal demangling.


--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -28,7 +28,7 @@ If not, see <http://www.gnu.org/licenses/>.  */
 
 /* This file exports one function; dlang_demangle.
 
-   This file imports strtol and strtod for decoding mangled literals.  */
+   This file imports strtol for decoding mangled literals.  */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -44,7 +44,6 @@ If not, see <http://www.gnu.org/licenses/>.  */
 #include 
 #else
 extern long strtol (const char *nptr, char **endptr, int base);
-extern double strtod (const char *nptr, char **endptr);
 #endif
 
 #include 
@@ -970,8 +969,6 @@ dlang_parse_real (string *decl, const char *mangled)
 {
   char buffer[64];
   int len = 0;
-  double value;
-  char *endptr;
 
   /* Handle NAN and +-INF.  */
   if (strncmp (mangled, "NAN", 3) == 0)
@@ -1035,14 +1032,10 @@ dlang_parse_real (string *decl, const char *mangled)
   mangled++;
 }
 
-  /* Convert buffer from hexadecimal to floating-point.  */
+  /* Write out the demangled hexadecimal, rather than trying to
+ convert the buffer into a floating-point value.  */
   buffer[len] = '\0';
-  value = strtod (buffer, &endptr);
-
-  if (endptr == NULL || endptr != (buffer + len))
-return NULL;
-
-  len = snprintf (buffer, sizeof(buffer), "%#g", value);
+  len = strlen (buffer);
   string_appendn (decl, buffer, len);
   return mangled;
 }
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -719,19 +719,19 @@ demangle.test!('\U000186a0')
 #
 --format=dlang
 _D8demangle17__T4testVde0A8P6Zv
-demangle.test!(42.)
+demangle.test!(0x0.A8p6)
 #
 --format=dlang
 _D8demangle16__T4testVdeA8P2Zv
-demangle.test!(42.)
+demangle.test!(0xA.8p2)
 #
 --format=dlang
 _D8demangle18__T4testVdeN0A8P6Zv
-demangle.test!(-42.)
+demangle.test!(-0x0.A8p6)
 #
 --format=dlang
 _D8demangle31__T4testVde0F6E978D4FDF3B646P7Zv
-demangle.test!(123.456)
+demangle.test!(0x0.F6E978D4FDF3B646p7)
 #
 --format=dlang
 _D8demangle15__T4testVdeNANZv
@@ -747,27 +747,27 @@ demangle.test!(-Inf)
 #
 --format=dlang
 _D8demangle23__T4testVfe0FFP128Zv
-demangle.test!(3.40282e+38)
+demangle.test!(0x0.FFp128)
 #
 --format=dlang
 _D8demangle32__T4testVde0F8P1024Zv
-demangle.test!(1.79769e+308)
+demangle.test!(0x0.F8p1024)
 #
 --format=dlang
 _D8demangle19__T4testVfe08PN125Zv
-demangle.test!(1.17549e-38)
+demangle.test!(0x0.8p-125)
 #
 --format=dlang
 _D8demangle20__T4testVde08PN1021Zv
-demangle.test!(2.22507e-308)
+demangle.test!(0x0.8p-1021)
 #
 --format=dlang
 _D8demangle51__T4testVrc0C4CDP4c0B666P6Zv
-demangle.test!(12.3000+45.6000i)
+demangle.test!(0x0.C4CDp4+0x0.B666p6i)
 #
 --format=dlang
 _D8demangle52__T4testVrcN0C4CDP4c0B666P6Zv
-demangle.test!(-12.3000+45.6000i)
+demangle.test!(-0x0.C4CDp4+0x0.B666p6i)
 #
 --format=dlang
 _D8demangle22__T4testVG3ua3_616263Zv
@@ -787,7 +787,7 @@ demangle.test!([1, 2, 3, 4])
 #
 --format=dlang
 _D8demangle25__T4testVAdA2e08P1eN08P1Zv
-demangle.test!([1.0, -1.0])
+demangle.test!([0x0.8p1, -0x0.8p1])
 #
 --format=dlang
 _D8demangle23__T4testVHiiA2i1i2i3i4Zv


Re: [PATCH] [dlang/phobos] S/390: Fix PR91628

2019-11-27 Thread Iain Buclaw
‐‐‐ Original Message ‐‐‐
On Wednesday, 27 November 2019 10:33, Robin Dapp  wrote:

> Hi,
>
> in order to not use a glibc-internal symbol anymore, this patch adds
> separate .S files for s390x and s390 that allow to obtain the tls offset.
>
> I bootstrapped on s390x -m64 and -m31 and test on s390x, s390 seeing no
> new regressions.
>

OK from me, what about earlier comments of using __asm__ in a C source file?

I wouldn't really object to converting all .S sources (infact I can do this 
myself) if it meant slightly better portability.

--
Iain



Re: [PATCH 0/13] D: Submission of D Front End

2017-06-06 Thread Iain Buclaw
On 29 May 2017 at 22:57, Eric Botcazou  wrote:
>> The upstream DMD compiler that comprises all components of the
>> standalone part is now implemented in D programming language itself.
>> However here GDC is still using the C++ implementation, it is a future
>> goal to switch to being a self-hosted compiler minus the GCC binding
>> interface (similar to Ada?), however extended platform support is
>> something I wish to address first before I make this a consideration.
>
> Yes, the Ada compiler is written in Ada and the glue code (called gigi) lives
> in ada/gcc-interface and is written in C++.
>
> --
> Eric Botcazou

OK, so there should be no surprises when d/dfrontend itself is
replaced by D sources.

Iain.


Re: [PATCH 9/13] D: D2 Testsuite Dejagnu files.

2017-06-06 Thread Iain Buclaw
On 31 May 2017 at 11:11, Matthias Klose  wrote:
> On 30.05.2017 16:32, Mike Stump wrote:
>> On May 28, 2017, at 2:16 PM, Iain Buclaw  wrote:
>>>
>>> This patch adds D language support to the GCC test suite.
>>
>> Ok.  If you could ensure that gcc without D retains all it's goodness and 
>> that gcc with D works on 2 different systems, that will help ensure 
>> integration smoothness.
>>
>> Something this large can be integration tested on a svn/git branch, if you 
>> need others to help out.
>
> I built the library (x86 and ARM32) and the D frontend on several Debian
> architectures and OSes (Linux, KFreeBSD, Hurd) in the past, but can do that 
> with
> the proposed patches again. A svn/git branch would be helpful for that, if a
> recent test is required.
>
> Matthias

Indeed, I have all cross-compilers running on explore.dgnu.org at
least.  A little hello world program should give a rough idea of which
targets are supported by libphobos - x86/64, ARM/64, MIPS/64 and
PPC/64 should be either supported or partial.  And if partial, then I
suspect that it's only because there's a missing 'CRuntime_xxx'
version define in the gcc/config patches.  Although I only use gdc on
Linux myself, the reference D compiler is tested on x86/Linux, OSX,
Solaris, and FreeBSD.  I'll optimistically say we should work on these
as well, although off the top of my head, the module dso support may
need looking at in the library.

Iain.


Re: [PATCH 9/13] D: D2 Testsuite Dejagnu files.

2017-06-06 Thread Iain Buclaw
On 31 May 2017 at 01:32, Mike Stump  wrote:
> On May 28, 2017, at 2:16 PM, Iain Buclaw  wrote:
>>
>> This patch adds D language support to the GCC test suite.
>
> Ok.  If you could ensure that gcc without D retains all it's goodness and 
> that gcc with D works on 2 different systems, that will help ensure 
> integration smoothness.
>
> Something this large can be integration tested on a svn/git branch, if you 
> need others to help out.
>

It would probably be easier for me to maintain also, rather than
continuously regenerating patches each time I make an update to
reflect something that changed in GCC.

Iain.


Re: MinGW compilation warnings in libiberty's waitpid.c

2017-06-06 Thread Iain Buclaw
On 30 May 2017 at 19:10, Joel Brobecker  wrote:
>> This has been on my todo-list for a little while, as re-syncing is
>> something I normally do after pushing D language support updates into
>> libiberty.  However I decided to give it a wait until I got all
>> pending patches in, the last of which I'm just pushing in now.
>
> That's very kind of you to help us with that :). Thank you!
>

I ended up not having time before going on holiday.  If the resync
hasn't already been done, I'll do it now.

Iain.


Re: [PATCH 0/13] D: Submission of D Front End

2017-06-12 Thread Iain Buclaw
On 12 June 2017 at 20:34, Richard Sandiford
 wrote:
> [Disclaimer: I can't approve any of this :-)]
>
> Iain Buclaw  writes:
>>   001 - The front-end (DMD) language implementation and license.
>>   002 - The front-end (GDC) implementation.
>>   003 - The front-end (GDC) changelogs (here be dragons).
>>   004 - The front-end (GDC) config, makefile, and manpages.
>>   005 - GCC configuration file changes and documentation.
>>   006 - Add D language support to GCC proper.
>>   007 - Add D language support to GCC targets.
>>   008 - D2 Testsuite tests.
>>   009 - D2 Testsuite Dejagnu files.
>>   010 - The D runtime library and license.
>>   011 - GCC builtins and runtime support (part of D runtime)
>>   012 - The Phobos runtime library and license.
>>   013 - Phobos config, makefiles, and testsuite.
>
> Just checking, but is it right that of these, the only parts that
> touch generic code are:
>
>>   005 - GCC configuration file changes and documentation.
>>   006 - Add D language support to GCC proper.
>
> Both seem fairly small (bar the autogenerated bits) and almost
> unobjectionable.
>

That is correct.


>>   007 - Add D language support to GCC targets.
>
> In a sense you get to define what's correct here.
>

I've tried to keep a close relationship to where
TARGET_CPU_CPP_BUILTINS and TARGET_OS_CPP_BUILTINS are defined.  The
versions emitted are documented in the D spec.


>>   009 - D2 Testsuite Dejagnu files.
>
> Already approved by Mike.
>
> If that's all, then that's pretty impressive. :-)
>
> I'm not sure who this is a question to really, but how much value is
> there in reviewing the other patches?  Maybe people who know the
> frontend interface well could comment on that part, but would anyone
> here be able to do a meaningful review of the core frontend?  And AIUI
> some of the patches are straight imports from an external upstream.
>

Patches 002 and 004 would also be points of interest, as they interact
with the GCC code and build scripts respectively.  I'm sure there are
parts in there where people will have questions, I certainly will have
questions over whether there's ways to improve things too.


> I was just wondering whether, once 5, 6 and 7 have been reviewed,
> accepting the rest would be a policy decision, or whether there
> was a plan for someone to review the whole series.
>

Patches 001 and 008 are maintained at github.com/dlang/dmd, and
patches 010 and 012 at github.com/dlang/druntime and
github.com/dlang/phobos.  The rest may only be 10% of the entire set,
but that covers everything that was written by both myself, and others
who've contributed t gdc.


> (Sorry if this was discussed and I missed it.)
>

I might be able to dig up some comments from a few years back when I
first proposed this, but otherwise no, I've not seen it discussed yet.

Regards
Iain.


Re: [PATCH 0/13] D: Submission of D Front End

2017-06-12 Thread Iain Buclaw
On 13 June 2017 at 01:22, Mike Stump  wrote:
> On Jun 12, 2017, at 11:34 AM, Richard Sandiford 
>  wrote:
>>
>> I'm not sure who this is a question to really, but how much value is
>> there in reviewing the other patches?
>
>> Maybe people who know the
>> frontend interface well could comment on that part, but would anyone
>> here be able to do a meaningful review of the core frontend?  And AIUI
>> some of the patches are straight imports from an external upstream.
>>
>> I was just wondering whether, once 5, 6 and 7 have been reviewed,
>> accepting the rest would be a policy decision, or whether there
>> was a plan for someone to review the whole series.
>
> So Iain might not have the whole game plan pre-arranged.  My guess is that it 
> isn't yet.  So, technically, people can argue for or against the FE as the 
> want, but ultimately, the SC I think gets to make the decision in the form of 
> accepting the FE contribution and appointing a FE maintainer.  If they say 
> yes, then that person can technically self-review the changes to the 
> non-shared bits.  For the shared bits, the usual maintainer for those bits 
> should review and approve those bits.  For example, the testsuite changes are 
> reviewed by the testsuite maintainer; I've done that, so that's done.  If 
> there are doc changes, a doc reviewer will review those bits and so on.
>
> I'd expect that for the changes that aren't shared, we treat it kinda like we 
> do for a new port.  There, we usually have a person or two go through and 
> weigh in where useful and help refine things a little.  If someone wants to 
> help out and volunteer to do this, they will.  If not, then we just trust the 
> FE coming in.  The SC will weigh in if they want the contribution contingent 
> upon a review.  Of course, the global reviewers and/or the SC might be able 
> to clarify, as they keep track of the little details better than I, the above 
> is just my guess to help get the process started.


Right, I actually gave no forewarning other than via IRC, where it got
an acknowledgement from Jakub and Richi, if I recall right, the
response was asking if the SC has formally accepted D and myself as a
maintainer.  The answer is 'no' on that front.  My initial intent was
to get things in motion again, after they were abruptly halted 4 years
ago.

Regards,
Iain.


Re: [PATCH 2/13] D: The front-end (GDC) implementation.

2017-06-13 Thread Iain Buclaw
On 13 June 2017 at 19:29, Joseph Myers  wrote:
> As I read it, the front end has functions with names such as error, but no
> useful i18n will actually occur because the functions in d-diagnostic.cc
> format the messages with xvasprintf before passing to the common
> diagnostic code.
>

That could be changed I guess to interact with
diagnostic_report_diagnostic() directly, rather than just being a high
level wrapper around gcc error_at()/warning_at().

> But will exgettext nevertheless extract messages from the dfrontend code,
> if the functions happen to have string arguments in the same position as
> the generic diagnostic functions do?  If so, I think that should be
> disabled, to avoid putting a lot of messages in gcc.pot that won't
> actually be translated.  (If actual i18n support is desired, it should be
> shared with other users of the front end, which would mean using dgettext
> to extract translations in a different domain from the default GCC one,
> and so the messages shouldn't go in gcc.pot anyway.)
>

I would say I'm open to i18n, however upstream D probably wouldn't be.
However as it is my intention to eventually switch the dfrontend
sources to D, exgettext extracting messages would cease to be a
problem.

> In d-target.cc you have code like:
>
> +  else if (global.params.isLinux)
> +{
> +  /* sizeof(pthread_mutex_t) for Linux.  */
> +  if (global.params.is64bit)
> +   return global.params.isLP64 ? 40 : 32;
> +  else
> +   return global.params.isLP64 ? 40 : 24;
> +}
>
> which feels like it belongs in the config/ configuration for each target
> (as a target hook returning the required information), not in the D front
> end code.  I'm not clear what global.params.is64bit is meant to mean; it
> looks like "this is x86_64, possibly x32" in this patch.  These values
> aren't correct in general anyway; on AArch64, glibc has pthread_mutex_t of
> size 48 for LP64 and 32 for ILP32; on HPPA (only ILP32 supported for
> Linux) it's 48.
>

That is something that I have been meaning to handle better.  I was
originally thinking something along the lines of it being determined
at configure time.  Then again, it's only use is for the dfrontend to
generate a lowering of synchronized statements that looks like:

static byte[] critsec;
_d_criticalenter(critsec.ptr);
try { ... }
finally {
_d_criticalexit(critsec.ptr);
}

Returning a size that is large enough for all would work also in the worst case.


There are a number of fields in global.params that I would prefer
removed from the shared frontend.  I when through them all with a
co-collaborator on the core dlang team during Dconf, but I wouldn't
hold my breath for it to happen.


> You have two new target macros TARGET_CPU_D_BUILTINS and
> TARGET_OS_D_BUILTINS.  You're missing any documentation for them in
> tm.texi.in.  And we prefer target hooks to macros.  So please try to
> convert them to (documented) target hooks.  (See c-family/c-target.def,
> and c_target_objs etc., for how there can be hooks that are specific to
> particular front ends.  See the comment in config/default-c.c regarding
> how to deal with a mixture of OS-dependent and architecture-dependent
> hooks.)
>

OK, thanks for the suggestion!

Iain.


Re: [PATCH 11/13] D: GCC builtins and runtime support.

2017-06-13 Thread Iain Buclaw
On 13 June 2017 at 19:38, Joseph Myers  wrote:
> Presumably all of these GCC-specific files should have the GCC Runtime
> Library Exception notice.
>

OK, noted.  I will update them.


Re: [PATCH 13/13] D: Phobos config, makefiles, and testsuite.

2017-06-13 Thread Iain Buclaw
On 13 June 2017 at 19:41, Joseph Myers  wrote:
> There appear to be various GPLv2 notices with old FSF addresses in here.
> Where those are on source files (as opposed to generated files), they
> should be updated to the usual GPLv3+ notice for GCC (and I'd expect FSF
> copyright notices throughout the contributed GCC-specific files, not
> "Copyright (C) 2012 Iain Buclaw").
>

I'll have a look, though it sounds like very old files from before I
got the assignment papers sorted out that missed being updated when I
sifted through them.

Regards,
Iain.


Re: [PATCH 2/13] D: The front-end (GDC) implementation.

2017-06-14 Thread Iain Buclaw
On 14 June 2017 at 00:41, Iain Buclaw  wrote:
> On 13 June 2017 at 19:29, Joseph Myers  wrote:
>> You have two new target macros TARGET_CPU_D_BUILTINS and
>> TARGET_OS_D_BUILTINS.  You're missing any documentation for them in
>> tm.texi.in.  And we prefer target hooks to macros.  So please try to
>> convert them to (documented) target hooks.  (See c-family/c-target.def,
>> and c_target_objs etc., for how there can be hooks that are specific to
>> particular front ends.  See the comment in config/default-c.c regarding
>> how to deal with a mixture of OS-dependent and architecture-dependent
>> hooks.)
>>
>
> OK, thanks for the suggestion!
>

Just to make sure I understand the structure correct.  There are a a
lot of files that would be involved.

- d/d-target.def: Define the hooks.
- d/d-target.h: Data definitions, extern gcc_targetdm;
- d/d-target-def.h: Default initializers (if applicable?)
- config.gcc: Add d_target_objs, assign platform and cpu files to it
as necessary.
- config/cpu/cpu-d.c: For each CPU that needs it, new file.  Here
would go CPU-related versions.
- config/os-d.c: For each OS that needs it, new file.  Here would go
OS and CRuntime versions, and other information like
sizeof(pthread_mutex_t).
- config/default-d.c: Define targetdm.
- config/glibc-d.c (others): Replaces default-d.c.
- config/t-glibc (others): Add build rules for above source file.
- Makefile.in: Add genhooks for d-target-hooks-def.h, build rule for default-d.c

I think that covers everything.

Regards
Iain


[PATCH v2 3/13] D: The front-end (GDC) changelogs.

2017-06-24 Thread Iain Buclaw
On 28 May 2017 at 23:11, Iain Buclaw  wrote:
> This patch just includes all changelogs for the D front-end (GDC),
> going back to the dawn of time itself.
>
> Change logs for the DMD front-end and libraries are kept on the dlang site.
>

Updated changelogs following updates to [patch 2/13].

Regards
Iain.


03-v2-d-frontend-changelogs.patch.xz
Description: application/xz


[PATCH v2 4/13] D: The front-end (GDC) config, makefile, and manpages.

2017-06-24 Thread Iain Buclaw
On 28 May 2017 at 23:12, Iain Buclaw  wrote:
> This patch adds the D frontend language configure make files, as
> described on the anatomy of a language front-end.
>

Only change since previous is adding D_TARGET_OBJS as per comments on
use of targetdm.

Regards,
Iain.

---
diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
new file mode 100644
index 000..b0999b93d30
--- /dev/null
+++ b/gcc/d/Make-lang.in
@@ -0,0 +1,274 @@
+# Make-lang.in -- Top level -*- makefile -*- fragment for the D frontend.
+# Copyright (C) 2006-2017 Free Software Foundation, Inc.
+
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# This file provides the language dependent support in the main Makefile.
+
+# Installation name.
+
+D_INSTALL_NAME = $(shell echo gdc|sed '$(program_transform_name)')
+D_TARGET_INSTALL_NAME = $(target_noncanonical)-$(shell echo gdc|sed '$(program_transform_name)')
+
+# Name of phobos library
+D_LIBPHOBOS = -DLIBPHOBOS=\"gphobos\"
+
+# The name for selecting d in LANGUAGES.
+d: cc1d$(exeext)
+
+# Tell GNU make to ignore these if they exist.
+.PHONY: d
+
+# Create the compiler driver for D.
+CFLAGS-d/d-spec.o += $(DRIVER_DEFINES) $(D_LIBPHOBOS)
+
+GDC_OBJS = $(GCC_OBJS) d/d-spec.o
+gdc$(exeext): $(GDC_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
+	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
+	  $(GDC_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
+	  $(EXTRA_GCC_LIBS) $(LIBS)
+
+# Create a version of the gdc driver which calls the cross-compiler.
+gdc-cross$(exeext): gdc$(exeext)
+	-rm -f gdc-cross$(exeext)
+	cp gdc$(exeext) gdc-cross$(exeext)
+
+# Filter out pedantic and virtual overload warnings.
+d-warn = $(filter-out -pedantic -Woverloaded-virtual, $(STRICT_WARN))
+
+# D Frontend has slightly relaxed warnings compared to rest of GDC.
+DMD_WARN_CXXFLAGS = -Wno-deprecated -Wstrict-aliasing -Wuninitialized
+DMD_COMPILE = $(subst $(WARN_CXXFLAGS), $(DMD_WARN_CXXFLAGS), $(COMPILE))
+DMDGEN_COMPILE = $(subst $(COMPILER), $(COMPILER_FOR_BUILD), $(DMD_COMPILE))
+
+# D Frontend object files.
+D_FRONTEND_OBJS = \
+	d/argtypes.o d/aav.o d/access.o d/aliasthis.o d/apply.o d/arrayop.o \
+	d/attrib.o d/canthrow.o d/checkedint.o d/clone.o d/cond.o \
+	d/constfold.o d/cppmangle.o d/ctfeexpr.o d/dcast.o d/dclass.o \
+	d/declaration.o d/delegatize.o d/denum.o d/dimport.o d/dinterpret.o \
+	d/dmacro.o d/dmangle.o d/dmodule.o d/doc.o d/dscope.o d/dstruct.o \
+	d/dsymbol.o d/dtemplate.o d/dversion.o d/entity.o d/escape.o \
+	d/expression.o d/file.o d/filename.o d/func.o d/hdrgen.o \
+	d/identifier.o d/imphint.o d/init.o d/inline.o d/intrange.o d/json.o \
+	d/lexer.o d/mtype.o d/nogc.o d/newdelete.o d/nspace.o d/objc.o \
+	d/opover.o d/optimize.o d/outbuffer.o d/parse.o d/rmem.o \
+	d/rootobject.o d/sapply.o d/sideeffect.o d/speller.o d/statement.o \
+	d/statementsem.o d/staticassert.o d/stringtable.o d/tokens.o d/traits.o \
+	d/unittests.o d/utf.o d/utils.o
+
+# D Frontend generated files.
+D_GENERATED_SRCS = d/id.c d/id.h d/impcnvtab.c
+D_GENERATED_OBJS = d/id.o d/impcnvtab.o
+
+# Language-specific object files for D.
+D_OBJS = \
+	d/d-attribs.o d/d-builtins.o d/d-codegen.o d/d-convert.o \
+	d/d-diagnostic.o d/d-frontend.o d/d-incpath.o d/d-lang.o \
+	d/d-longdouble.o d/d-target.o d/decl.o d/expr.o d/imports.o \
+	d/intrinsics.o d/modules.o d/runtime.o d/toir.o d/typeinfo.o d/types.o
+
+# All language-specific object files for D.
+D_ALL_OBJS = $(D_FRONTEND_OBJS) $(D_GENERATED_OBJS) $(D_OBJS) $(D_TARGET_OBJS)
+
+d_OBJS = $(D_ALL_OBJS) d/d-spec.o
+
+cc1d$(exeext): $(D_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS)
+	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
+		$(D_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
+
+# Documentation.
+
+D_TEXI_FILES = \
+	d/gdc.texi \
+	$(gcc_docdir)/include/fdl.texi \
+	$(gcc_docdir)/include/gpl_v3.texi \
+	$(gcc_docdir)/include/gcc-common.texi \
+	gcc-vers.texi
+
+doc/gdc.info: $(D_TEXI_FILES)
+	if test "x$(BUILD_INFO)" = xinfo; then \
+	  rm -f doc/gdc.info*; \
+	  $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
+		-I $(gcc_docdir)/include -o $@ $<; \
+	else true; fi
+
+doc/gdc.dvi: $(D_TEXI_FILES)
+	$(TEXI2DVI) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
+
+doc/gdc.pdf: $(D_TEXI_FILES)
+	$(TEXI2PDF) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
+
+$(build_htmldir)/d/index.html: $(D_TEXI_FILES)
+	$(mkinsta

[PATCH v2 6/13] D: Add D language support to GCC proper.

2017-06-24 Thread Iain Buclaw
On 28 May 2017 at 23:15, Iain Buclaw  wrote:
> This patch adds D language support to GCC itself.
>

Updates from the previous are:

 - Applied patch on rs6000/rs6000.c also to powerpcspe/powerpcspe.c.
 - Added d/dfrontend sources picked up by exgettext to list of EXCLUDES.

---
---
gcc/ChangeLog

	* config/powerpcspe/powerpcspe.c (rs6000_output_function_epilogue):
	Support GNU D by using 0 as the language type.
	* config/rs6000/rs6000.c (rs6000_output_function_epilogue):
	Support GNU D by using 0 as the language type.
	* dwarf2out.c (is_dlang): New function.
	(gen_compile_unit_die): Use DW_LANG_D for D.
	(declare_in_namespace): Return module die for D, instead of adding
	extra declarations into the namespace.
	(gen_namespace_die): Generate DW_TAG_module for D.
	(gen_decl_die, dwarf2out_decl): Handle CONST_DECLSs for D.
	* gcc.c (default_compilers): Add entries for ".d", ".dd" and ".di".

gcc/po/ChangeLog:

* EXCLUDES: Add sources from d/dfrontend.

diff --git a/gcc/config/powerpcspe/powerpcspe.c b/gcc/config/powerpcspe/powerpcspe.c
index 73d608fd805..19f3dd06247 100644
--- a/gcc/config/powerpcspe/powerpcspe.c
+++ b/gcc/config/powerpcspe/powerpcspe.c
@@ -31921,11 +31921,12 @@ rs6000_output_function_epilogue (FILE *file,
 	 use language_string.
 	 C is 0.  Fortran is 1.  Pascal is 2.  Ada is 3.  C++ is 9.
 	 Java is 13.  Objective-C is 14.  Objective-C++ isn't assigned
-	 a number, so for now use 9.  LTO, Go and JIT aren't assigned numbers
-	 either, so for now use 0.  */
+	 a number, so for now use 9.  LTO, Go, D and JIT aren't assigned
+	 numbers either, so for now use 0.  */
   if (lang_GNU_C ()
 	  || ! strcmp (language_string, "GNU GIMPLE")
 	  || ! strcmp (language_string, "GNU Go")
+	  || ! strcmp (language_string, "GNU D")
 	  || ! strcmp (language_string, "libgccjit"))
 	i = 0;
   else if (! strcmp (language_string, "GNU F77")
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 79dccba1dce..83f1cf84efc 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -28986,11 +28986,12 @@ rs6000_output_function_epilogue (FILE *file,
 	 use language_string.
 	 C is 0.  Fortran is 1.  Pascal is 2.  Ada is 3.  C++ is 9.
 	 Java is 13.  Objective-C is 14.  Objective-C++ isn't assigned
-	 a number, so for now use 9.  LTO, Go and JIT aren't assigned numbers
-	 either, so for now use 0.  */
+	 a number, so for now use 9.  LTO, Go, D, and JIT aren't assigned
+	 numbers either, so for now use 0.  */
   if (lang_GNU_C ()
 	  || ! strcmp (language_string, "GNU GIMPLE")
 	  || ! strcmp (language_string, "GNU Go")
+	  || ! strcmp (language_string, "GNU D")
 	  || ! strcmp (language_string, "libgccjit"))
 	i = 0;
   else if (! strcmp (language_string, "GNU F77")
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index c277d27e8e8..08fc6fbfc60 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -5083,6 +5083,16 @@ is_ada (void)
   return lang == DW_LANG_Ada95 || lang == DW_LANG_Ada83;
 }
 
+/* Return TRUE if the language is D.  */
+
+static inline bool
+is_dlang (void)
+{
+  unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
+
+  return lang == DW_LANG_D;
+}
+
 /* Remove the specified attribute if present.  Return TRUE if removal
was successful.  */
 
@@ -23599,6 +23609,8 @@ gen_compile_unit_die (const char *filename)
 	language = DW_LANG_ObjC;
   else if (strcmp (language_string, "GNU Objective-C++") == 0)
 	language = DW_LANG_ObjC_plus_plus;
+  else if (strcmp (language_string, "GNU D") == 0)
+	language = DW_LANG_D;
   else if (dwarf_version >= 5 || !dwarf_strict)
 	{
 	  if (strcmp (language_string, "GNU Go") == 0)
@@ -25182,7 +25194,7 @@ declare_in_namespace (tree thing, dw_die_ref context_die)
 
   if (ns_context != context_die)
 {
-  if (is_fortran ())
+  if (is_fortran () || is_dlang ())
 	return ns_context;
   if (DECL_P (thing))
 	gen_decl_die (thing, NULL, NULL, ns_context);
@@ -25205,7 +25217,7 @@ gen_namespace_die (tree decl, dw_die_ref context_die)
 {
   /* Output a real namespace or module.  */
   context_die = setup_namespace_context (decl, comp_unit_die ());
-  namespace_die = new_die (is_fortran ()
+  namespace_die = new_die (is_fortran () || is_dlang ()
 			   ? DW_TAG_module : DW_TAG_namespace,
 			   context_die, decl);
   /* For Fortran modules defined in different CU don't add src coords.  */
@@ -25272,7 +25284,7 @@ gen_decl_die (tree decl, tree origin, struct vlr_context *ctx,
   break;
 
 case CONST_DECL:
-  if (!is_fortran () && !is_ada ())
+  if (!is_fortran () && !is_ada () && !is_dlang ())
 	{
 	  /* The individual enumerators of an enum type get output when we output
 	 the Dwarf representation of the

[PATCH v2 7/13] D: Add D language support to GCC targets.

2017-06-24 Thread Iain Buclaw
On 28 May 2017 at 23:15, Iain Buclaw  wrote:
> This patch add D language support to targets of GCC itself.
>
> These are used to declare pre-defined version identifiers in the D
> language that describe something about the target that the front-end
> itself is unable to obtain.  Version conditions in D can be thought of
> as being like the target macros of C, but that where the similarity
> ends.
>
> ---

This is a complete redo of this patch as per comments on putting
target-related code into d-target.def, instead of macros in various
backend headers.  Also adding documentation to tm.texi.

This has only been tested in x86_64/linux, everything else is just a
straightforward copy based from it.  I'm ok with trimming this down to
only have what's been tested, and adding on the other targets later on
an individual built and verified basis.

---
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 67d69c1c0d2..49f6fbb9173 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -546,6 +546,8 @@ tm_include_list=@tm_include_list@
 tm_defines=@tm_defines@
 tm_p_file_list=@tm_p_file_list@
 tm_p_include_list=@tm_p_include_list@
+tm_d_file_list=@tm_d_file_list@
+tm_d_include_list=@tm_d_include_list@
 build_xm_file_list=@build_xm_file_list@
 build_xm_include_list=@build_xm_include_list@
 build_xm_defines=@build_xm_defines@
@@ -840,6 +842,7 @@ BCONFIG_H = bconfig.h $(build_xm_file_list)
 CONFIG_H  = config.h  $(host_xm_file_list)
 TCONFIG_H = tconfig.h $(xm_file_list)
 TM_P_H= tm_p.h$(tm_p_file_list)
+TM_D_H= tm_d.h$(tm_d_file_list)
 GTM_H = tm.h  $(tm_file_list) insn-constants.h
 TM_H  = $(GTM_H) insn-flags.h $(OPTIONS_H)
 
@@ -897,9 +900,11 @@ EXCEPT_H = except.h $(HASHTAB_H)
 TARGET_DEF = target.def target-hooks-macros.h target-insns.def
 C_TARGET_DEF = c-family/c-target.def target-hooks-macros.h
 COMMON_TARGET_DEF = common/common-target.def target-hooks-macros.h
+D_TARGET_DEF = d/d-target.def target-hooks-macros.h
 TARGET_H = $(TM_H) target.h $(TARGET_DEF) insn-modes.h insn-codes.h
 C_TARGET_H = c-family/c-target.h $(C_TARGET_DEF)
 COMMON_TARGET_H = common/common-target.h $(INPUT_H) $(COMMON_TARGET_DEF)
+D_TARGET_H = d/d-target.h $(D_TARGET_DEF)
 MACHMODE_H = machmode.h mode-classes.def insn-modes.h
 HOOKS_H = hooks.h $(MACHMODE_H)
 HOSTHOOKS_DEF_H = hosthooks-def.h $(HOOKS_H)
@@ -1172,6 +1177,9 @@ C_TARGET_OBJS=@c_target_objs@
 # Target specific, C++ specific object file
 CXX_TARGET_OBJS=@cxx_target_objs@
 
+# Target specific, D specific object file
+D_TARGET_OBJS=@d_target_objs@
+
 # Target specific, Fortran specific object file
 FORTRAN_TARGET_OBJS=@fortran_target_objs@
 
@@ -1760,6 +1768,7 @@ bconfig.h: cs-bconfig.h ; @true
 tconfig.h: cs-tconfig.h ; @true
 tm.h: cs-tm.h ; @true
 tm_p.h: cs-tm_p.h ; @true
+tm_d.h: cs-tm_d.h ; @true
 
 cs-config.h: Makefile
 	TARGET_CPU_DEFAULT="" \
@@ -1786,6 +1795,11 @@ cs-tm_p.h: Makefile
 	HEADERS="$(tm_p_include_list)" DEFINES="" \
 	$(SHELL) $(srcdir)/mkconfig.sh tm_p.h
 
+cs-tm_d.h: Makefile
+	TARGET_CPU_DEFAULT="" \
+	HEADERS="$(tm_d_include_list)" DEFINES="" \
+	$(SHELL) $(srcdir)/mkconfig.sh tm_d.h
+
 # Don't automatically run autoconf, since configure.ac might be accidentally
 # newer than configure.  Also, this writes into the source directory which
 # might be on a read-only file system.  If configured for maintainer mode
@@ -2115,6 +2129,12 @@ default-c.o: config/default-c.c
 CFLAGS-prefix.o += -DPREFIX=\"$(prefix)\" -DBASEVER=$(BASEVER_s)
 prefix.o: $(BASEVER)
 
+# Files used by the D language front end.
+
+default-d.o: config/default-d.c
+	$(COMPILE) $<
+	$(POSTCOMPILE)
+
 # Language-independent files.
 
 DRIVER_DEFINES = \
@@ -2403,6 +2423,15 @@ s-common-target-hooks-def-h: build/genhooks$(build_exeext)
 	 common/common-target-hooks-def.h
 	$(STAMP) s-common-target-hooks-def-h
 
+d/d-target-hooks-def.h: s-d-target-hooks-def-h; @true
+
+s-d-target-hooks-def-h: build/genhooks$(build_exeext)
+	$(RUN_GEN) build/genhooks$(build_exeext) "D Target Hook" \
+	 > tmp-d-target-hooks-def.h
+	$(SHELL) $(srcdir)/../move-if-change tmp-d-target-hooks-def.h \
+	 d/d-target-hooks-def.h
+	$(STAMP) s-d-target-hooks-def-h
+
 # check if someone mistakenly only changed tm.texi.
 # We use a different pathname here to avoid a circular dependency.
 s-tm-texi: $(srcdir)/doc/../doc/tm.texi
@@ -2426,6 +2455,7 @@ s-tm-texi: build/genhooks$(build_exeext) $(srcdir)/doc/tm.texi.in
 	  && ( test $(srcdir)/doc/tm.texi -nt $(srcdir)/target.def \
 	|| test $(srcdir)/doc/tm.texi -nt $(srcdir)/c-family/c-target.def \
 	|| test $(srcdir)/doc/tm.texi -nt $(srcdir)/common/common-target.def \
+	|| test $(srcdir)/doc/tm.texi -nt $(srcdir)/d/d-target.def \
 	  ); then \
 	  echo >&2 ; \
 	  echo You should edit $(srcdir)/doc/tm.texi.in rather than $(srcdir)/doc/tm.texi . >&2 ; \

[PATCH v2 9/13] D: D2 Testsuite Dejagnu files.

2017-06-24 Thread Iain Buclaw
On 28 May 2017 at 23:16, Iain Buclaw  wrote:
> This patch adds D language support to the GCC testsuite.
>
> As well as generating the DejaGNU options for compile and link tests,
> handles the conversion from DMD-style compiler options to GDC.
>
> ---

Added a few extra comments for procedures, altering dmd2dg to write
out flags converted to dejagnu in-place, instead on newlines.

In the other testsuite patch, added new tests to accompany fixes that
have been made since the last patch.

Regards
Iain.

---
diff --git a/gcc/testsuite/gdc.test/d_do_test.exp b/gcc/testsuite/gdc.test/d_do_test.exp
new file mode 100644
index 000..7a9da72037e
--- /dev/null
+++ b/gcc/testsuite/gdc.test/d_do_test.exp
@@ -0,0 +1,385 @@
+#   Copyright (C) 2012-2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Test using the DMD testsuite.
+# Load support procs.
+load_lib gdc-dg.exp
+
+#
+# Convert DMD arguments to GDC equivalent
+#
+
+proc gdc-convert-args { base args } {
+set out ""
+
+foreach arg [split [lindex $args 0] " "] {
+# List of switches kept in ASCII collated order.
+if { [regexp -- {^-I([\w+/-]+)} $arg pattern path] } {
+lappend out "-I$base/$path"
+
+} elseif { [regexp -- {^-J([\w+/-]+)} $arg pattern path] } {
+lappend out "-J$base/$path"
+
+} elseif [string match "-allinst" $arg] {
+lappend out "-fall-instantiations"
+
+} elseif { [string match "-boundscheck" $arg]
+ || [string match "-boundscheck=on" $arg] } {
+lappend out "-fbounds-check"
+
+} elseif { [string match "-boundscheck=off" $arg]
+   || [string match "-noboundscheck" $arg] } {
+lappend out "-fno-bounds-check"
+
+} elseif [string match "-boundscheck=safeonly" $arg] {
+lappend out "-fbounds-check=safeonly"
+
+} elseif [string match "-c" $arg] {
+lappend out "-c"
+
+} elseif [string match "-d" $arg] {
+lappend out "-Wno-deprecated"
+
+} elseif [string match "-de" $arg] {
+lappend out "-Wdeprecated"
+lappend out "-Werror"
+
+} elseif [string match "-debug" $arg] {
+lappend out "-fdebug"
+
+} elseif [string match "-dip1000" $arg] {
+lappend out "-ftransition=safe"
+
+} elseif [string match "-dip25" $arg] {
+lappend out "-ftransition=dip25"
+
+} elseif [string match "-dw" $arg] {
+lappend out "-Wdeprecated"
+lappend out "-Wno-error"
+
+} elseif [string match "-fPIC" $arg] {
+lappend out "-fPIC"
+
+} elseif { [string match "-g" $arg]
+   || [string match "-gc" $arg] } {
+lappend out "-g"
+
+} elseif [string match "-inline" $arg] {
+lappend out "-finline-functions"
+
+} elseif [regexp -- {^-mv=([\w+=./-]+)} $arg pattern value] {
+lappend out "-fmodule-filepath=$value"
+
+} elseif [string match "-O" $arg] {
+lappend out "-O2"
+
+} elseif [string match "-property" $arg] {
+lappend out "-fproperty"
+
+} elseif [string match "-release" $arg] {
+lappend out "-frelease"
+
+} elseif [regexp -- {^-transition=(\w+)} $arg pattern value] {
+lappend out "-ftransition=$value"
+
+} elseif [string match "-unittest" $arg] {
+lappend out "-funittest"
+
+} elseif [string match "-verrors=spec" $arg] {
+lappend out "-Wspeculative"
+
+} elseif [regexp -- {^-verrors=(\d+)} $arg pattern num] {
+lappend out "-fmax-errors=$num"
+
+} elseif [regexp -- {^-version=(\w+)} $arg pattern value] {
+lappend out "-fversion=$value"
+
+} else

[PATCH v2 11/13] D: GCC builtins and runtime support.

2017-06-24 Thread Iain Buclaw
On 28 May 2017 at 23:17, Iain Buclaw  wrote:
> This patch adds GCC builtins and runtime support for GDC compiled code.
>
>   - module __entrypoint defines the C main function.  Its contents are
> parsed and compiled in during compilation, but only if needed.
>   - module gcc.atomic is a deprecated module that defines templated
> __sync builtins.  It's original user, core.atomic, now uses the GCC
> __atomic builtins.
>   - module gcc.attribute exposes GDC-specific attributes.
>   - module gcc.backtrace implements backtrace support for GDC.
>   - module gcc.builtins exposes GCC builtins to D code.
>   - module gcc.config exposes things determined at configure time to D code.
>   - module gcc.deh implements D unwind EH.
>   - module gcc.libbacktrace defines C bindings to libbacktrace.
>   - module gcc.unwind defines C bindings to libgcc unwind library.
>   - libgphobos.spec contains a list of libraries to link in that are
> dependencies of D runtime and/or the Phobos standard library.  It is
> used by the GDC driver.
>
> ---

Added GCC Runtime Library Exception to gcc modules as requested.

Regards
Iain.

---
diff --git a/libphobos/libdruntime/__entrypoint.di b/libphobos/libdruntime/__entrypoint.di
new file mode 100644
index 000..d04fe5d0889
--- /dev/null
+++ b/libphobos/libdruntime/__entrypoint.di
@@ -0,0 +1,56 @@
+/* GDC -- D front-end for GCC
+   Copyright (C) 2013 Free Software Foundation, Inc.
+
+   GCC is free software; you can redistribute it and/or modify it under
+   the terms of the GNU General Public License as published by the Free
+   Software Foundation; either version 3, or (at your option) any later
+   version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+   for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.
+*/
+
+/* This module provides the C main() function supplied by the user's program.  */
+
+module __entrypoint;
+
+extern(C):
+
+/* The D main() function supplied by the user's program
+
+   It always has `_Dmain` symbol name and uses C calling convention.
+   But D frontend returns its type as `extern(D)` because of Issue 9028.
+   As we need to deal with actual calling convention we have to mark it
+   as `extern(C)` and use its symbol name.
+*/
+
+int _Dmain(char[][] args);
+int _d_run_main(int argc, char **argv, void* mainFunc);
+
+/* Substitutes for the C main() function.  Just calls into d_run_main with
+   the default main function.  Applications are free to implement their own
+   main function and call the _d_run_main function themselves with any main
+   function.
+*/
+
+int main(int argc, char **argv)
+{
+return _d_run_main(argc, argv, &_Dmain);
+}
+
+/* This is apparently needed on Solaris because the C tool chain seems to
+   expect the main function to be called _main.  It needs both not just one!
+*/
+
+version (Solaris)
+int _main(int argc, char** argv)
+{
+return main(argc, argv);
+}
+
diff --git a/libphobos/libdruntime/gcc/attribute.d b/libphobos/libdruntime/gcc/attribute.d
new file mode 100644
index 000..2498c27e7cc
--- /dev/null
+++ b/libphobos/libdruntime/gcc/attribute.d
@@ -0,0 +1,33 @@
+// GNU D Compiler attribute support declarations.
+// Copyright (C) 2013-2017 Free Software Foundation, Inc.
+
+// GCC is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3, or (at your option) any later
+// version.
+
+// GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+module gcc.attribute;
+
+private struct Attribute(A...)
+{
+A args;
+}
+
+auto attribute(A...)(A args) if(A.length > 0 && is(A[0] == string))
+{
+return Attribute!A(args);
+}
diff --git a/libphobos/libdruntime/gcc/backtrace.d b/libphobos/libdruntime/gcc/backtrace.d
new file mode 100644
index 000..c24a53a42fb
--- /dev/null
+++ b/libphobos/libdruntime/gcc/backtrace.d
@@ -0,0 +1,575 @@
+// GNU D Compiler routines for st

[PATCH] Add self as maintainer of D front-end and libphobos

2017-06-24 Thread Iain Buclaw
Hi,

As per message on the D language being accepted, this adds myself as a
maintainer of the D front-end and libphobos runtime library.

David, should this wait until the rest has been approved?

Thanks,
Iain.

---
ChangeLog:

2017-06-24  Iain Buclaw  

	* MAINTAINERS: Add myself D front-end and libphobos maintainer.

diff --git a/MAINTAINERS b/MAINTAINERS
index c76c1818d08..0efa5dd45f6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -147,6 +147,7 @@ BRIG (HSAIL) front end	Pekka Jääskeläinen	
 BRIG (HSAIL) front end 	Martin Jambor		
 c++			Jason Merrill		
 c++			Nathan Sidwell		
+D front end		Iain Buclaw		
 go			Ian Lance Taylor	
 objective-c/c++		Mike Stump		
 objective-c/c++		Iain Sandoe		
@@ -174,6 +175,7 @@ libquadmath		Jakub Jelinek		
 libvtv			Caroline Tice		
 libhsail-rt		Pekka Jääskeläinen	
 libhsail-rt		Martin Jambor		
+libphobos		Iain Buclaw		
 line map		Dodji Seketeli		
 soft-fp			Joseph Myers		
 scheduler (+ haifa)	Jim Wilson		


Re: [PATCH v3 1/14] D: The front-end (DMD) language implementation and license.

2017-11-21 Thread Iain Buclaw
On 13 November 2017 at 00:20, Andrei Alexandrescu  wrote:
> On 11/06/2017 01:46 PM, Iain Buclaw wrote:
>>
>> On 25 October 2017 at 03:06, Jeff Law  wrote:
>>>
>>> On 10/18/2017 01:33 AM, Iain Buclaw wrote:
>>>>
>>>> On 6 October 2017 at 14:51, Ian Lance Taylor  wrote:
>>>>>
>>>>> On Fri, Oct 6, 2017 at 1:34 AM, Iain Buclaw 
>>>>> wrote:
>>>>>>
>>>>>>
>>>>>> Out of curiosity, I did have a look at some of the tops of gofrontend
>>>>>> sources this morning.  They are all copyright the Go Authors, and are
>>>>>> licensed as BSD.  So I'm not sure if having copyright FSF and
>>>>>> distributing under GPL is strictly required.  And from a maintenance
>>>>>> point of view, it would be easier to merge in upstream changes as-is
>>>>>> without some diff/merging tool.
>>>>>
>>>>>
>>>>> The GCC steering committee accepted the gofrontend code under a
>>>>> non-GPL license with the understanding that the master code would live
>>>>> in a separate repository that would be mirrored into the GCC repo (the
>>>>> master repository for gofrontend is currently at
>>>>> https://go.googlesource.com/gofrontend/).  Personally I don't see a
>>>>> problem with doing the same for the D frontend.
>>>>>
>>>>> Ian
>>>>
>>>>
>>>> Should I request that maybe Donald from FSF chime in here?  I'd rather
>>>> avoid another stalemate on this.
>>>
>>> Absolutely, though RMS should probably be included on any discussion
>>> with Donald.  I think the FSF needs to chime in and I think the steering
>>> committee needs to chime in once we've got guidance from the FSF.
>>>
>>> The first and most important question that needs to be answered is
>>> whether or not the FSF would be OK including the DMD bits with the
>>> license (boost) as-is into GCC.
>>>
>>> If that's not acceptable, then we'd have to look at some kind of script
>>> to fix the copyrights.
>>> Jeff
>>>
>>
>> Assuming then, that we'll ship with all copyright notices amended to
>> be copyright FSF and GPL licensed - that can be fixed up in a later
>> patch - is there anything further needed to push this review process
>> further?
>>
>> Iain.
>
>
> Hi Jeff, Ian, Joseph: thanks for your consideration. Is there anything we
> can do on our side to move things forward? Please advise, thanks!
>
> Andrei
>

Ping?

I was recently made aware that upstream DMD has a pending patch to
switch copyright ownership of all its sources to "The D Language
Foundation", however it now seems blocked pending on the outcome here.

Iain.


Re: [PING][PATCH v3 1/14] D: The front-end (DMD) language implementation and license.

2018-06-09 Thread Iain Buclaw
On 15 March 2018 at 20:05, Iain Buclaw  wrote:
> On 17 February 2018 at 16:08, Iain Buclaw  wrote:
>> On 25 October 2017 at 03:06, Jeff Law  wrote:
>>> On 10/18/2017 01:33 AM, Iain Buclaw wrote:
>>>> On 6 October 2017 at 14:51, Ian Lance Taylor  wrote:
>>>>> On Fri, Oct 6, 2017 at 1:34 AM, Iain Buclaw  
>>>>> wrote:
>>>>>>
>>>>>> Out of curiosity, I did have a look at some of the tops of gofrontend
>>>>>> sources this morning.  They are all copyright the Go Authors, and are
>>>>>> licensed as BSD.  So I'm not sure if having copyright FSF and
>>>>>> distributing under GPL is strictly required.  And from a maintenance
>>>>>> point of view, it would be easier to merge in upstream changes as-is
>>>>>> without some diff/merging tool.
>>>>>
>>>>> The GCC steering committee accepted the gofrontend code under a
>>>>> non-GPL license with the understanding that the master code would live
>>>>> in a separate repository that would be mirrored into the GCC repo (the
>>>>> master repository for gofrontend is currently at
>>>>> https://go.googlesource.com/gofrontend/).  Personally I don't see a
>>>>> problem with doing the same for the D frontend.
>>>>>
>>>>> Ian
>>>>
>>>> Should I request that maybe Donald from FSF chime in here?  I'd rather
>>>> avoid another stalemate on this.
>>> Absolutely, though RMS should probably be included on any discussion
>>> with Donald.  I think the FSF needs to chime in and I think the steering
>>> committee needs to chime in once we've got guidance from the FSF.
>>>
>>> The first and most important question that needs to be answered is
>>> whether or not the FSF would be OK including the DMD bits with the
>>> license (boost) as-is into GCC.
>>>
>>> If that's not acceptable, then we'd have to look at some kind of script
>>> to fix the copyrights.
>>> Jeff
>>>
>>
>>
>> Just touching base here, hope you all had a good New Year.
>>
>> So far, I've only had a general "Yes this is fine" from Ted who's
>> managing the copyright assignments at the FSF.
>>
>> His his initial response being:
>> ---
>> If the D files are all Boost v.1 and we can get assignments from all
>> contributors, there is no problem including the files as there are
>> currently. Boost is compatible with GPLv3 or later since it is
>> basically a [permissive license][0].
>>
>> [0]: https://directory.fsf.org/wiki/License:Boost1.0
>> ---
>>
>> And subsequent follow-up:
>> ---
>> The questions that remain still are whether there are any unaccounted
>> for contributors to this (but I don't believe this is the case from
>> the first pass).  We have the assignment for the past and future code
>> from Digital Mars.  The second question, which is outside of my
>> discretion is deciding whether the Boost license is acceptable.  It
>> seems that it is compatible so it doesn't appear that incompatibility
>> is a problem, but of course there are still policy considerations.
>> These are currently being discussed on the mailing-list and I will add
>> this message to the thread.
>> ---
>>
>>
>> I have asked for clarity on a few more finer points, but still haven't
>> heard back after a number of attempts to get an answer back.
>>
>> Can we get discussion rolling again on this?
>>
>> Since the last message, upstream dmd has switched all copyrights to
>> "The D Language Foundation", which has been reflected downstream in
>> gdc.
>>
>> So, as a policy consideration from the SC, is it acceptable to have
>> the following notice at the top of all dfrontend/* sources?
>>
>> ---
>> Copyright (C) 2010-2018 by The D Language Foundation, All Rights Reserved
>> All Rights Reserved, written by Walter Bright
>> http://www.digitalmars.com
>> Distributed under the Boost Software License, Version 1.0.
>> (See accompanying file LICENSE or copy at 
>> http://www.boost.org/LICENSE_1_0.txt)
>> ---
>>
>> And if no, what should it instead be?
>>
>> There are no restrictions on changing the copyright to FSF and license as 
>> GPLv3+
>>
>> Regards
>> Iain.
>
> Tentative ping on this.
>
> I would submit a revived patch set, as active development has not
> stopped.  Just would like input on what would be preferential here.
>

Ping?

It would be nice to get any response here, from either yourselves or
the FSF, who've been silent for many months.  Having no guidance to go
off, I will just resubmit the current patches with upstream dmd
copyright modified as GPL next week when I have time.

Iain.


Re: [PATCH v3 1/14] D: The front-end (DMD) language implementation and license.

2018-02-17 Thread Iain Buclaw
On 25 October 2017 at 03:06, Jeff Law  wrote:
> On 10/18/2017 01:33 AM, Iain Buclaw wrote:
>> On 6 October 2017 at 14:51, Ian Lance Taylor  wrote:
>>> On Fri, Oct 6, 2017 at 1:34 AM, Iain Buclaw  wrote:
>>>>
>>>> Out of curiosity, I did have a look at some of the tops of gofrontend
>>>> sources this morning.  They are all copyright the Go Authors, and are
>>>> licensed as BSD.  So I'm not sure if having copyright FSF and
>>>> distributing under GPL is strictly required.  And from a maintenance
>>>> point of view, it would be easier to merge in upstream changes as-is
>>>> without some diff/merging tool.
>>>
>>> The GCC steering committee accepted the gofrontend code under a
>>> non-GPL license with the understanding that the master code would live
>>> in a separate repository that would be mirrored into the GCC repo (the
>>> master repository for gofrontend is currently at
>>> https://go.googlesource.com/gofrontend/).  Personally I don't see a
>>> problem with doing the same for the D frontend.
>>>
>>> Ian
>>
>> Should I request that maybe Donald from FSF chime in here?  I'd rather
>> avoid another stalemate on this.
> Absolutely, though RMS should probably be included on any discussion
> with Donald.  I think the FSF needs to chime in and I think the steering
> committee needs to chime in once we've got guidance from the FSF.
>
> The first and most important question that needs to be answered is
> whether or not the FSF would be OK including the DMD bits with the
> license (boost) as-is into GCC.
>
> If that's not acceptable, then we'd have to look at some kind of script
> to fix the copyrights.
> Jeff
>


Just touching base here, hope you all had a good New Year.

So far, I've only had a general "Yes this is fine" from Ted who's
managing the copyright assignments at the FSF.

His his initial response being:
---
If the D files are all Boost v.1 and we can get assignments from all
contributors, there is no problem including the files as there are
currently. Boost is compatible with GPLv3 or later since it is
basically a [permissive license][0].

[0]: https://directory.fsf.org/wiki/License:Boost1.0
---

And subsequent follow-up:
---
The questions that remain still are whether there are any unaccounted
for contributors to this (but I don't believe this is the case from
the first pass).  We have the assignment for the past and future code
from Digital Mars.  The second question, which is outside of my
discretion is deciding whether the Boost license is acceptable.  It
seems that it is compatible so it doesn't appear that incompatibility
is a problem, but of course there are still policy considerations.
These are currently being discussed on the mailing-list and I will add
this message to the thread.
---


I have asked for clarity on a few more finer points, but still haven't
heard back after a number of attempts to get an answer back.

Can we get discussion rolling again on this?

Since the last message, upstream dmd has switched all copyrights to
"The D Language Foundation", which has been reflected downstream in
gdc.

So, as a policy consideration from the SC, is it acceptable to have
the following notice at the top of all dfrontend/* sources?

---
Copyright (C) 2010-2018 by The D Language Foundation, All Rights Reserved
All Rights Reserved, written by Walter Bright
http://www.digitalmars.com
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
---

And if no, what should it instead be?

There are no restrictions on changing the copyright to FSF and license as GPLv3+

Regards
Iain.


[PING][PATCH v3 1/14] D: The front-end (DMD) language implementation and license.

2018-03-15 Thread Iain Buclaw
On 17 February 2018 at 16:08, Iain Buclaw  wrote:
> On 25 October 2017 at 03:06, Jeff Law  wrote:
>> On 10/18/2017 01:33 AM, Iain Buclaw wrote:
>>> On 6 October 2017 at 14:51, Ian Lance Taylor  wrote:
>>>> On Fri, Oct 6, 2017 at 1:34 AM, Iain Buclaw  wrote:
>>>>>
>>>>> Out of curiosity, I did have a look at some of the tops of gofrontend
>>>>> sources this morning.  They are all copyright the Go Authors, and are
>>>>> licensed as BSD.  So I'm not sure if having copyright FSF and
>>>>> distributing under GPL is strictly required.  And from a maintenance
>>>>> point of view, it would be easier to merge in upstream changes as-is
>>>>> without some diff/merging tool.
>>>>
>>>> The GCC steering committee accepted the gofrontend code under a
>>>> non-GPL license with the understanding that the master code would live
>>>> in a separate repository that would be mirrored into the GCC repo (the
>>>> master repository for gofrontend is currently at
>>>> https://go.googlesource.com/gofrontend/).  Personally I don't see a
>>>> problem with doing the same for the D frontend.
>>>>
>>>> Ian
>>>
>>> Should I request that maybe Donald from FSF chime in here?  I'd rather
>>> avoid another stalemate on this.
>> Absolutely, though RMS should probably be included on any discussion
>> with Donald.  I think the FSF needs to chime in and I think the steering
>> committee needs to chime in once we've got guidance from the FSF.
>>
>> The first and most important question that needs to be answered is
>> whether or not the FSF would be OK including the DMD bits with the
>> license (boost) as-is into GCC.
>>
>> If that's not acceptable, then we'd have to look at some kind of script
>> to fix the copyrights.
>> Jeff
>>
>
>
> Just touching base here, hope you all had a good New Year.
>
> So far, I've only had a general "Yes this is fine" from Ted who's
> managing the copyright assignments at the FSF.
>
> His his initial response being:
> ---
> If the D files are all Boost v.1 and we can get assignments from all
> contributors, there is no problem including the files as there are
> currently. Boost is compatible with GPLv3 or later since it is
> basically a [permissive license][0].
>
> [0]: https://directory.fsf.org/wiki/License:Boost1.0
> ---
>
> And subsequent follow-up:
> ---
> The questions that remain still are whether there are any unaccounted
> for contributors to this (but I don't believe this is the case from
> the first pass).  We have the assignment for the past and future code
> from Digital Mars.  The second question, which is outside of my
> discretion is deciding whether the Boost license is acceptable.  It
> seems that it is compatible so it doesn't appear that incompatibility
> is a problem, but of course there are still policy considerations.
> These are currently being discussed on the mailing-list and I will add
> this message to the thread.
> ---
>
>
> I have asked for clarity on a few more finer points, but still haven't
> heard back after a number of attempts to get an answer back.
>
> Can we get discussion rolling again on this?
>
> Since the last message, upstream dmd has switched all copyrights to
> "The D Language Foundation", which has been reflected downstream in
> gdc.
>
> So, as a policy consideration from the SC, is it acceptable to have
> the following notice at the top of all dfrontend/* sources?
>
> ---
> Copyright (C) 2010-2018 by The D Language Foundation, All Rights Reserved
> All Rights Reserved, written by Walter Bright
> http://www.digitalmars.com
> Distributed under the Boost Software License, Version 1.0.
> (See accompanying file LICENSE or copy at 
> http://www.boost.org/LICENSE_1_0.txt)
> ---
>
> And if no, what should it instead be?
>
> There are no restrictions on changing the copyright to FSF and license as 
> GPLv3+
>
> Regards
> Iain.

Tentative ping on this.

I would submit a revived patch set, as active development has not
stopped.  Just would like input on what would be preferential here.

Iain.


[PATCH 01/14] Add D front-end (DMD) language implementation and license.

2018-09-17 Thread Iain Buclaw
This patch adds the DMD front-end proper and license (Boost) files,
comprised of a lexer, parser, and semantic analyzer.

ftp://ftp.gdcproject.org/patches/v4/01-v4-d-frontend-dmd.patch

---
 gcc/d/dmd/access.c   |  670 +++
 gcc/d/dmd/aggregate.h|  335 ++
 gcc/d/dmd/aliasthis.c|  169 +
 gcc/d/dmd/aliasthis.h|   30 +
 gcc/d/dmd/apply.c|  150 +
 gcc/d/dmd/argtypes.c |  504 ++
 gcc/d/dmd/arrayop.c  |  638 +++
 gcc/d/dmd/arraytypes.h   |   62 +
 gcc/d/dmd/attrib.c   | 1604 ++
 gcc/d/dmd/attrib.h   |  275 +
 gcc/d/dmd/blockexit.c|  502 ++
 gcc/d/dmd/boostlicense.txt   |   23 +
 gcc/d/dmd/canthrow.c |  317 ++
 gcc/d/dmd/checkedint.c   |  564 ++
 gcc/d/dmd/checkedint.h   |   24 +
 gcc/d/dmd/clone.c| 1233 +
 gcc/d/dmd/compiler.h |   19 +
 gcc/d/dmd/complex_t.h|   71 +
 gcc/d/dmd/cond.c |  376 ++
 gcc/d/dmd/cond.h |  107 +
 gcc/d/dmd/constfold.c| 1932 +++
 gcc/d/dmd/cppmangle.c| 1109 
 gcc/d/dmd/ctfe.h |  267 +
 gcc/d/dmd/ctfeexpr.c | 2109 
 gcc/d/dmd/dcast.c| 3842 ++
 gcc/d/dmd/dclass.c   | 1958 +++
 gcc/d/dmd/declaration.c  | 2572 +
 gcc/d/dmd/declaration.h  |  899 
 gcc/d/dmd/delegatize.c   |  210 +
 gcc/d/dmd/denum.c|  757 +++
 gcc/d/dmd/dimport.c  |  501 ++
 gcc/d/dmd/dinterpret.c   | 7172 +
 gcc/d/dmd/dmacro.c   |  468 ++
 gcc/d/dmd/dmangle.c  |  897 
 gcc/d/dmd/dmodule.c  | 1444 +
 gcc/d/dmd/doc.c  | 2804 ++
 gcc/d/dmd/doc.h  |   14 +
 gcc/d/dmd/dscope.c   |  764 +++
 gcc/d/dmd/dstruct.c  | 1470 ++
 gcc/d/dmd/dsymbol.c  | 1803 +++
 gcc/d/dmd/dsymbol.h  |  406 ++
 gcc/d/dmd/dtemplate.c| 9009 +++
 gcc/d/dmd/dversion.c |  202 +
 gcc/d/dmd/entity.c   | 2392 +
 gcc/d/dmd/enum.h |   95 +
 gcc/d/dmd/errors.h   |   50 +
 gcc/d/dmd/escape.c   | 1234 +
 gcc/d/dmd/expression.c   | 6983 
 gcc/d/dmd/expression.h   | 1559 ++
 gcc/d/dmd/expressionsem.c| 8929 +++
 gcc/d/dmd/func.c | 5739 
 gcc/d/dmd/globals.h  |  315 ++
 gcc/d/dmd/hdrgen.c   | 3419 
 gcc/d/dmd/hdrgen.h   |   52 +
 gcc/d/dmd/iasm.c |   44 +
 gcc/d/dmd/iasmgcc.c  |  358 ++
 gcc/d/dmd/identifier.c   |  190 +
 gcc/d/dmd/identifier.h   |   49 +
 gcc/d/dmd/idgen.c|  503 ++
 gcc/d/dmd/impcnvgen.c|  599 +++
 gcc/d/dmd/imphint.c  |   72 +
 gcc/d/dmd/import.h   |   60 +
 gcc/d/dmd/init.c |  286 +
 gcc/d/dmd/init.h |  119 +
 gcc/d/dmd/initsem.c  |  920 
 gcc/d/dmd/intrange.c | 1109 
 gcc/d/dmd/intrange.h |  152 +
 gcc/d/dmd/json.c |  890 
 gcc/d/dmd/json.h |   17 +
 gcc/d/dmd/lexer.c| 2422 +
 gcc/d/dmd/lexer.h|   75 +
 gcc/d/dmd/macro.h|   45 +
 gcc/d/dmd/mangle.h   |   33 +
 gcc/d/dmd/mars.h |   95 +
 gcc/d/dmd/module.h   |  179 +
 gcc/d/dmd/mtype.c| 9606 ++
 gcc/d/dmd/mtype.h|  934 
 gcc/d/dmd/nogc.c |  241 +
 gcc/d/dmd/nspace.c   |  255 +
 gcc/d/dmd/nspace.h   |   38 +
 gcc/d/dmd/objc.c |   84 +
 gcc/d/dmd/objc.h |   53 +
 gcc/d/dmd/opover.c   | 1966 +++
 gcc/d/dmd/optimize.c | 1274 +
 gcc/d/dmd/parse.c| 8102 
 gcc/d/dmd/parse.h|  188 +
 gcc/d/dmd/readme.txt |   13 +
 gcc/d/dmd/root/aav.c |  192 +
 gcc/d/dmd/root/aav.h |   18 +
 gcc/d/dmd/root/array.h   |  235 +
 gcc/d/dmd/root/ctfloat.h |   47 +
 gcc/d/dmd/root/dcompat.h |   18 +
 gcc/d/dmd/root/file.c|  265 +
 gcc/d/dmd/root/file.h|   54 +
 gcc/d/dmd/root/filename.c|  679 +++
 gcc/d/dmd/root/filename.h|   51 +
 gcc/d/dmd/root/hash.h|   75 +
 gcc/d/dmd/root/object.h  |   60 +
 gcc/d/dmd/root/outbuffer.c   |  401 ++
 gcc/d/dmd/root/outbuffer.h   |   77 +
 gcc/d/dmd/root/port.h|   43 +
 gcc/d/dmd/root/rmem.c|  162 +
 gcc/d/dmd/root/rmem.h|   35 +
 gcc/d/dmd/root/root.h|   19 +
 gcc/d/dmd/root/rootobject.c  |   49 +
 gcc/d/dmd/root/speller.c |  294 ++
 gcc/d/dmd/root/speller.h |   14 +
 gcc/d/dmd/root/stringtable.c |  200 +
 gcc/d/dmd/root/stringtable.h |   57 +
 gcc/d/dmd/safe.c |  168 +
 gcc/d/dmd/sapply.c   |  156 +
 gcc/d/dmd/scope.h|  158 +
 gcc/d/dmd/sideeffect.c   |  439 ++
 gcc/d/dmd/statement.c| 1669 ++
 gcc/

[PATCH 03/14] Add D frontend (GDC) changelogs.

2018-09-17 Thread Iain Buclaw
This patch just includes all changelogs for the D front-end (GDC),
going back to the dawn of time itself.

---
 gcc/d/ChangeLog  |  332 ++
 gcc/d/ChangeLog-2006 |  954 +++
 gcc/d/ChangeLog-2007 | 1340 ++
 gcc/d/ChangeLog-2008 |  331 ++
 gcc/d/ChangeLog-2009 |  185 ++
 gcc/d/ChangeLog-2010 | 1484 ++
 gcc/d/ChangeLog-2011 | 1248 +++
 gcc/d/ChangeLog-2012 |  857 
 gcc/d/ChangeLog-2013 | 1221 ++
 gcc/d/ChangeLog-2014 |  660 +++
 gcc/d/ChangeLog-2015 |  771 ++
 gcc/d/ChangeLog-2016 | 1262 +++
 gcc/d/ChangeLog-2017 | 1175 +
 13 files changed, 11820 insertions(+)


03-v4-d-frontend-changelogs.patch.xz
Description: application/xz


[PATCH 02/14] Add D frontend (GDC) implementation.

2018-09-17 Thread Iain Buclaw
This patch adds the D front-end implementation, the only part of the
compiler that interacts with GCC directly, and being the parts that I
maintain, is something that I can talk about more directly.

For the actual code generation pass, that converts the front-end AST
to GCC trees, most parts use a separate Visitor interfaces to do a
certain kind of lowering, for instance, types.cc builds *_TYPE trees
from AST Type's.  The Visitor class is part of the DMD front-end, and
is defined in dfrontend/visitor.h.

There are also a few interfaces which have their headers in the DMD
frontend, but are implemented here because they do something that
requires knowledge of the GCC backend (d-target.cc), does something
that may not be portable, or differ between D compilers
(d-frontend.cc) or are a thin wrapper around something that is managed
by GCC (d-diagnostic.cc).

Many high level operations result in generation of calls to D runtime
library functions (runtime.def), all with require some kind of runtime
type information (typeinfo.cc).  The compiler also generates functions
for registering/deregistering compiled modules with the D runtime
library (modules.cc).

As well as the D language having it's own built-in functions
(intrinsics.cc), we also expose GCC builtins to D code via a
`gcc.builtins' module (d-builtins.cc), and give special treatment to a
number of UDAs that could be applied to functions (d-attribs.cc).


That is roughly the high level jist of how things are currently organized.

ftp://ftp.gdcproject.org/patches/v4/02-v4-d-frontend-gdc.patch

---
 gcc/d/d-attribs.c |  846 +++
 gcc/d/d-builtins.cc   | 1162 +++
 gcc/d/d-codegen.cc| 2730 +++
 gcc/d/d-convert.cc|  807 +++
 gcc/d/d-diagnostic.cc |  347 +
 gcc/d/d-frontend.cc   |  534 +++
 gcc/d/d-incpath.cc|  195 +++
 gcc/d/d-lang.cc   | 1847 
 gcc/d/d-longdouble.cc |  204 +++
 gcc/d/d-spec.c|  493 +++
 gcc/d/d-target-def.h  |   20 +
 gcc/d/d-target.cc |  502 +++
 gcc/d/d-target.def|   60 +
 gcc/d/d-target.h  |   34 +
 gcc/d/d-tree.def  |   34 +
 gcc/d/d-tree.h|  669 +
 gcc/d/decl.cc | 2177 
 gcc/d/expr.cc | 3158 +
 gcc/d/imports.cc  |  203 +++
 gcc/d/intrinsics.cc   |  895 
 gcc/d/intrinsics.def  |  154 ++
 gcc/d/lang-specs.h|   29 +
 gcc/d/lang.opt|  366 +
 gcc/d/longdouble.h|  136 ++
 gcc/d/modules.cc  |  849 +++
 gcc/d/runtime.cc  |  315 
 gcc/d/runtime.def |  224 +++
 gcc/d/toir.cc | 1438 +++
 gcc/d/typeinfo.cc | 1667 ++
 gcc/d/types.cc|  980 +
 gcc/d/verstr.h|1 +
 31 files changed, 23076 insertions(+)


[PATCH 04/14] Add D front-end (GDC) config, Makefile, and manpages.

2018-09-17 Thread Iain Buclaw
LD) $(BUILD_LINKER_FLAGS) $(BUILD_LDFLAGS) -o $@ $^
+
+d/impcvgen: d/impcnvgen.dmdgen.o
+	+$(LINKER_FOR_BUILD) $(BUILD_LINKER_FLAGS) $(BUILD_LDFLAGS) -o $@ $^
+
+# Generated sources.
+d/id.c: d/idgen
+	cd d && ./idgen
+
+# idgen also generates id.h; just verify it exists.
+d/id.h: d/id.c
+
+d/impcnvtab.c: d/impcvgen
+	cd d && ./impcvgen
+
+d/%.dmdgen.o: $(srcdir)/d/dmd/%.c
+	$(DMDGEN_COMPILE) $(D_INCLUDES) $<
+	$(POSTCOMPILE)
diff --git a/gcc/d/config-lang.in b/gcc/d/config-lang.in
new file mode 100644
index 000..aa6058cef71
--- /dev/null
+++ b/gcc/d/config-lang.in
@@ -0,0 +1,33 @@
+# config-lang.in -- Top level configure fragment for gcc D frontend.
+# Copyright (C) 2006-2018 Free Software Foundation, Inc.
+
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Configure looks for the existence of this file to auto-config each language.
+# We define several parameters used by configure:
+#
+# language	- name of language as it would appear in $(LANGUAGES)
+# compilers	- value to add to $(COMPILERS)
+
+language="d"
+
+compilers="cc1d\$(exeext)"
+
+target_libs="target-libphobos target-zlib target-libbacktrace"
+
+gtfiles="\$(srcdir)/d/d-tree.h \$(srcdir)/d/d-builtins.cc \$(srcdir)/d/d-lang.cc \$(srcdir)/d/typeinfo.cc"
+
+# Do not build by default.
+build_by_default="no"
diff --git a/gcc/d/gdc.texi b/gcc/d/gdc.texi
new file mode 100644
index 000..ea79352a452
--- /dev/null
+++ b/gcc/d/gdc.texi
@@ -0,0 +1,749 @@
+\input texinfo @c -*-texinfo-*-
+@setfilename gdc.info
+@settitle The GNU D Compiler
+
+@c Merge the standard indexes into a single one.
+@syncodeindex fn cp
+@syncodeindex vr cp
+@syncodeindex ky cp
+@syncodeindex pg cp
+@syncodeindex tp cp
+
+@include gcc-common.texi
+
+@c Copyright years for this manual.
+@set copyrights-d 2006-2018
+
+@copying
+@c man begin COPYRIGHT
+Copyright @copyright{} @value{copyrights-d} Free Software Foundation, Inc.
+
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.3 or
+any later version published by the Free Software Foundation; with no
+Invariant Sections, the Front-Cover Texts being (a) (see below), and
+with the Back-Cover Texts being (b) (see below).
+A copy of the license is included in the
+@c man end
+section entitled ``GNU Free Documentation License''.
+@ignore
+@c man begin COPYRIGHT
+man page gfdl(7).
+@c man end
+@end ignore
+
+@c man begin COPYRIGHT
+
+(a) The FSF's Front-Cover Text is:
+
+ A GNU Manual
+
+(b) The FSF's Back-Cover Text is:
+
+ You have freedom to copy and modify this GNU Manual, like GNU
+ software.  Copies published by the Free Software Foundation raise
+ funds for GNU development.
+@c man end
+@end copying
+
+@ifinfo
+@format
+@dircategory Software development
+@direntry
+* gdc: (gdc).   A GCC-based compiler for the D language
+@end direntry
+@end format
+
+@insertcopying
+@end ifinfo
+
+@titlepage
+@title The GNU D Compiler
+@versionsubtitle
+@author David Friedman, Iain Buclaw
+
+@page
+@vskip 0pt plus 1filll
+Published by the Free Software Foundation @*
+51 Franklin Street, Fifth Floor@*
+Boston, MA 02110-1301, USA@*
+@sp 1
+@insertcopying
+@end titlepage
+@contents
+@page
+
+@node Top
+@top Introduction
+
+This manual describes how to use @command{gdc}, the GNU compiler for
+the D programming language.  This manual is specifically about
+@command{gdc}.  For more information about the D programming
+language in general, including language specifications and standard
+package documentation, see @uref{http://dlang.org/}.
+
+@menu
+* Copying:: The GNU General Public License.
+* GNU Free Documentation License::
+How you can share and copy this manual.
+* Invoking gdc::How to run gdc.
+* Index::   Index.
+@end menu
+
+
+@include gpl_v3.texi
+
+@include fdl.texi
+
+
+@node Invoking gdc
+@chapter Invoking gdc
+
+@c man title gdc A GCC-based compiler for the D language
+
+@ignore
+@c man begin SYNOPSIS gdc
+gdc [@option{-c}|@option{-S}] [@option{-g}] [@option{-pg}]
+[@option{-O}@var{level}] [@option{-W}@var{warn}@dots{}]
+[@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
+[@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}]
+  

[PATCH 05/14] Add GCC configuration file changes and documentation.

2018-09-17 Thread Iain Buclaw

This patch adds the D language front-end to GCC documentation and configuration files, as described on the anatomy of a language front-end.

---
ChangeLog:

	* Makefile.def (target_modules): Add libphobos.
	(flags_to_pass): Add GDC_FOR_TARGET.
	(dependencies): Add dependency from configure-target-libphobos to
	configure-target-zlib.  Add dependency from all-target-libphobos to
	all-target-zlib.
	(language): Add languge d.
	* Makefile.in: Rebuild.
	* Makefile.tpl (BUILT_EXPORTS): Add GDC.
	(HOST_EXPORTS): Add GDC.
	(BASE_TARGET_EXPORTS): Add GDC.
	(GDC_FOR_BUILD, GDC_FOR_TARGET): New variables.
	(EXTRA_HOST_FLAGS): Add GDC.
	(EXTRA_TARGET_FLAGS): Add GDC.
	* config-ml.in: Treat GDC and GDCFLAGS like other compiler/flag
	environment variables.
	* configure: Rebuild.
	* configure.ac: Add target-libphobos to target_libraries.  Set and
	substitute GDC_FOR_BUILD and GDC_FOR_TARGET.

config/ChangeLog:

	* multi.m4: Set GDC.

gcc/ChangeLog:

	* doc/contrib.texi (Contributors): Add self for the D frontend.
	* doc/frontends.texi (G++ and GCC): Mention D as a supported language.
	* doc/install.texi (Configuration): Mention libphobos as an option for
	--enable-shared.  Mention d as an option for --enable-languages.
	(Testing): Mention check-d as a target.
	* doc/invoke.texi (Overall Options): Mention .d, .dd, and .di as file
	name suffixes.  Mention d as a -x option.
	* doc/sourcebuild.texi (Top Level): Mention libphobos.
	* doc/standards.texi (Standards): Add section on D language.

---
 Makefile.def |   9 +
 Makefile.in  | 506 +++
 Makefile.tpl |  11 +
 config-ml.in |  16 +-
 config/multi.m4  |   3 +-
 configure| 217 -
 configure.ac |   9 +-
 gcc/doc/contrib.texi |   3 +
 gcc/doc/frontends.texi   |   3 +-
 gcc/doc/install.texi |  10 +-
 gcc/doc/invoke.texi  |  10 +
 gcc/doc/sourcebuild.texi |   4 +
 gcc/doc/standards.texi   |   6 +
 13 files changed, 797 insertions(+), 10 deletions(-)

diff --git a/Makefile.def b/Makefile.def
index 31c2bbcd549..538a189e129 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -153,6 +153,7 @@ target_modules = { module= libgfortran; };
 target_modules = { module= libobjc; };
 target_modules = { module= libgo; };
 target_modules = { module= libhsail-rt; };
+target_modules = { module= libphobos; };
 target_modules = { module= libtermcap; no_check=true;
missing=mostlyclean;
missing=clean;
@@ -278,6 +279,8 @@ flags_to_pass = { flag= FLAGS_FOR_TARGET ; };
 flags_to_pass = { flag= GFORTRAN_FOR_TARGET ; };
 flags_to_pass = { flag= GOC_FOR_TARGET ; };
 flags_to_pass = { flag= GOCFLAGS_FOR_TARGET ; };
+flags_to_pass = { flag= GDC_FOR_TARGET ; };
+flags_to_pass = { flag= GDCFLAGS_FOR_TARGET ; };
 flags_to_pass = { flag= LD_FOR_TARGET ; };
 flags_to_pass = { flag= LIPO_FOR_TARGET ; };
 flags_to_pass = { flag= LDFLAGS_FOR_TARGET ; };
@@ -544,6 +547,9 @@ dependencies = { module=configure-target-libgo; on=all-target-libstdc++-v3; };
 dependencies = { module=all-target-libgo; on=all-target-libbacktrace; };
 dependencies = { module=all-target-libgo; on=all-target-libffi; };
 dependencies = { module=all-target-libgo; on=all-target-libatomic; };
+dependencies = { module=configure-target-libphobos; on=configure-target-zlib; };
+dependencies = { module=all-target-libphobos; on=all-target-zlib; };
+dependencies = { module=all-target-libphobos; on=all-target-libatomic; };
 dependencies = { module=configure-target-libstdc++-v3; on=configure-target-libgomp; };
 dependencies = { module=configure-target-liboffloadmic; on=configure-target-libgomp; };
 dependencies = { module=configure-target-libsanitizer; on=all-target-libstdc++-v3; };
@@ -557,6 +563,7 @@ dependencies = { module=all-target-liboffloadmic; on=all-target-libgomp; };
 dependencies = { module=install-target-libgo; on=install-target-libatomic; };
 dependencies = { module=install-target-libgfortran; on=install-target-libquadmath; };
 dependencies = { module=install-target-libgfortran; on=install-target-libgcc; };
+dependencies = { module=install-target-libphobos; on=install-target-libatomic; };
 dependencies = { module=install-target-libsanitizer; on=install-target-libstdc++-v3; };
 dependencies = { module=install-target-libsanitizer; on=install-target-libgcc; };
 dependencies = { module=install-target-libvtv; on=install-target-libstdc++-v3; };
@@ -598,6 +605,8 @@ languages = { language=go;	gcc-check-target=check-go;
 lib-check-target=check-gotools; };
 languages = { language=brig;	gcc-check-target=check-brig;
 lib-check-target=check-target-libhsail-rt; };
+languages = { language=d;	gcc-check-target=check-d;
+lib-check-target=check-target-libphobos; };
 
 // Toplevel bootstrap
 bootstrap_stage = { id=1 ; };
diff --git a/Makefile.in b/Makefile.in
index e0dfad337a6..c12e402b822 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -156,6 +156,8 @@ BUILD_EXPORTS = \
 	G

[PATCH 06/14] Add patches for D language support in GCC proper.

2018-09-17 Thread Iain Buclaw

This patch adds D language support to GCC itself.

---
gcc/ChangeLog

	* config/powerpcspe/powerpcspe.c (rs6000_output_function_epilogue):
	Support GNU D by using 0 as the language type.
	* config/rs6000/rs6000.c (rs6000_output_function_epilogue):
	Support GNU D by using 0 as the language type.
	* dwarf2out.c (is_dlang): New function.
	(gen_compile_unit_die): Use DW_LANG_D for D.
	(declare_in_namespace): Return module die for D, instead of adding
	extra declarations into the namespace.
	(gen_namespace_die): Generate DW_TAG_module for D.
	(gen_decl_die, dwarf2out_decl): Handle CONST_DECLSs for D.
	(prune_unused_types_walk_local_classes): Handle
	DW_tag_interface_type.
	(prune_unused_types_walk): Handle DW_tag_interface_type same as
	other kinds of aggregates.
	* gcc.c (default_compilers): Add entries for ".d", ".dd" and ".di".

gcc/po/ChangeLog:

* EXCLUDES: Add sources from d/dfrontend.
---
 gcc/config/powerpcspe/powerpcspe.c |  5 ++--
 gcc/config/rs6000/rs6000.c |  5 ++--
 gcc/dwarf2out.c| 23 +
 gcc/gcc.c  |  1 +
 gcc/po/EXCLUDES| 40 ++
 5 files changed, 65 insertions(+), 9 deletions(-)

diff --git a/gcc/config/powerpcspe/powerpcspe.c b/gcc/config/powerpcspe/powerpcspe.c
index dea1eab1188..8b157174473 100644
--- a/gcc/config/powerpcspe/powerpcspe.c
+++ b/gcc/config/powerpcspe/powerpcspe.c
@@ -32026,11 +32026,12 @@ rs6000_output_function_epilogue (FILE *file)
 	 use language_string.
 	 C is 0.  Fortran is 1.  Pascal is 2.  Ada is 3.  C++ is 9.
 	 Java is 13.  Objective-C is 14.  Objective-C++ isn't assigned
-	 a number, so for now use 9.  LTO, Go and JIT aren't assigned numbers
-	 either, so for now use 0.  */
+	 a number, so for now use 9.  LTO, Go, D and JIT aren't assigned
+	 numbers either, so for now use 0.  */
   if (lang_GNU_C ()
 	  || ! strcmp (language_string, "GNU GIMPLE")
 	  || ! strcmp (language_string, "GNU Go")
+	  || ! strcmp (language_string, "GNU D")
 	  || ! strcmp (language_string, "libgccjit"))
 	i = 0;
   else if (! strcmp (language_string, "GNU F77")
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index a36e6140ecb..97ca2dac289 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -28405,11 +28405,12 @@ rs6000_output_function_epilogue (FILE *file)
 	 use language_string.
 	 C is 0.  Fortran is 1.  Pascal is 2.  Ada is 3.  C++ is 9.
 	 Java is 13.  Objective-C is 14.  Objective-C++ isn't assigned
-	 a number, so for now use 9.  LTO, Go and JIT aren't assigned numbers
-	 either, so for now use 0.  */
+	 a number, so for now use 9.  LTO, Go, D, and JIT aren't assigned
+	 numbers either, so for now use 0.  */
   if (lang_GNU_C ()
 	  || ! strcmp (language_string, "GNU GIMPLE")
 	  || ! strcmp (language_string, "GNU Go")
+	  || ! strcmp (language_string, "GNU D")
 	  || ! strcmp (language_string, "libgccjit"))
 	i = 0;
   else if (! strcmp (language_string, "GNU F77")
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 48c50378622..47877faebd7 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -5521,6 +5521,16 @@ is_ada (void)
   return lang == DW_LANG_Ada95 || lang == DW_LANG_Ada83;
 }
 
+/* Return TRUE if the language is D.  */
+
+static inline bool
+is_dlang (void)
+{
+  unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
+
+  return lang == DW_LANG_D;
+}
+
 /* Remove the specified attribute if present.  Return TRUE if removal
was successful.  */
 
@@ -24550,6 +24560,8 @@ gen_compile_unit_die (const char *filename)
 	language = DW_LANG_ObjC;
   else if (strcmp (language_string, "GNU Objective-C++") == 0)
 	language = DW_LANG_ObjC_plus_plus;
+  else if (strcmp (language_string, "GNU D") == 0)
+	language = DW_LANG_D;
   else if (dwarf_version >= 5 || !dwarf_strict)
 	{
 	  if (strcmp (language_string, "GNU Go") == 0)
@@ -26150,7 +26162,7 @@ declare_in_namespace (tree thing, dw_die_ref context_die)
 
   if (ns_context != context_die)
 {
-  if (is_fortran ())
+  if (is_fortran () || is_dlang ())
 	return ns_context;
   if (DECL_P (thing))
 	gen_decl_die (thing, NULL, NULL, ns_context);
@@ -26173,7 +26185,7 @@ gen_namespace_die (tree decl, dw_die_ref context_die)
 {
   /* Output a real namespace or module.  */
   context_die = setup_namespace_context (decl, comp_unit_die ());
-  namespace_die = new_die (is_fortran ()
+  namespace_die = new_die (is_fortran () || is_dlang ()
 			   ? DW_TAG_module : DW_TAG_namespace,
 			   context_die, decl);
   /* For Fortran modules defined in different CU don't add src coords.  */
@@ -26239,7 +26251,7 @@ gen_decl_die (tree decl, tree origin, struct vlr_context *ctx,
   break;
 
 case CONST_DECL:
-  if (!is_fortran () && !is_ada ())
+  if (!is_fortran () && !is_ada () && !is_dlang ())
 	{
 	  /* The individual enumerators of an enum type get output when we output
 	 th

[PATCH 07/14] Add patches for D language support in GCC targets.

2018-09-17 Thread Iain Buclaw

This patch add D language support to targets of GCC itself.

These are mostly used to declare pre-defined version identifiers in the D language that describe something about the target that the front-end itself is unable to obtain.  Version conditions in D can be thought of as being like the target macros of C, but that where the similarity ends.

The only other target hook present is TARGET_D_CRITSEC_SIZE, which returns the size of pthread_mutex_t, or whatever equivalent type the OS provides.

---
gcc/ChangeLog

	* gcc/Makefile.in (tm_d_file_list, tm_d_include_list,
	TM_D_H, D_TARGET_DEF, D_TARGET_H, D_TARGET_OBJS): New variables.
	(tm_d.h, cs-tm_d.h, default-d.o, d/d-target-hooks-def.h,
	s-d-target-hooks-def-h): New rules.
	(s-tm-texi): Also check timestamp on d-target.def.
	(generated_files): Add TM_D_H and d-target-hooks-def.h.
	(build/genhooks.o): Also depend on D_TARGET_DEF.
	* gcc/config.gcc (tm_d_file, d_target_objs, target_has_targetdm):
	New variables.
	* config/aarch64/aarch64-d.c: New file.
	* config/aarch64/aarch64-linux.h (GNU_USER_TARGET_D_CRITSEC_SIZE):
	Define.
	* config/aarch64/aarch64-protos.h (aarch64_d_target_versions): New
	prototype.
	* config/aarch64/aarch64.h (TARGET_D_CPU_VERSIONS): Define.
	* config/aarch64/t-aarch64 (aarch64-d.o): New rule.
	* config/arm/arm-d.c: New file.
	* config/arm/arm-protos.h (arm_d_target_versions): New prototype.
	* config/arm/arm.h (TARGET_D_CPU_VERSIONS): Define.
	* config/arm/linux-eabi.h (EXTRA_TARGET_D_OS_VERSIONS): Define.
	* config/arm/t-arm (arm-d.o): New rule.
	* config/default-d.c: New file.
	* config/glibc-d.c: New file.
	* config/gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/i386/i386-d.c: New file.
	* config/i386/i386-protos.h (ix86_d_target_versions): New prototype.
	* config/i386/i386.h (TARGET_D_CPU_VERSIONS): Define.
	* config/i386/linux-common.h (EXTRA_TARGET_D_OS_VERSIONS,
	GNU_USER_TARGET_D_CRITSEC_SIZE): Define.
	* config/i386/t-i386 (i386-d.o): New rule.
	* config/kfreebsd-gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/kopensolaris-gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/linux-android.h (ANDROID_TARGET_D_OS_VERSIONS): Define.
	* config/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/mips/linux-common.h (EXTRA_TARGET_D_OS_VERSIONS): Define.
	* config/mips/mips-d.c: New file.
	* config/mips/mips-protos.h (mips_d_target_versions): New prototype.
	* config/mips/mips.h (TARGET_D_CPU_VERSIONS): Define.
	* config/mips/t-mips (mips-d.o): New rule.
	* config/powerpcspe/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/powerpcspe/linux64.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/powerpcspe/powerpcspe-d.c: New file.
	* config/powerpcspe/powerpcspe-protos.h (rs6000_d_target_versions):
	New prototype.
	* config/powerpcspe/powerpcspe.h (TARGET_D_CPU_VERSIONS): Define.
	* config/powerpcspe/t-powerpcspe (powerpcspe-d.o): New rule.
	* config/riscv/riscv-d.c: New file.
	* config/riscv/riscv-protos.h (riscv_d_target_versions): New
	prototype.
	* config/riscv/riscv.h (TARGET_D_CPU_VERSIONS): Define.
	* config/riscv/t-riscv (riscv-d.o): New rule.
	* config/rs6000/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/rs6000/linux64.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/rs6000/rs6000-d.c: New file.
	* config/rs6000/rs6000-protos.h (rs6000_d_target_versions): New
	prototype.
	* config/rs6000/t-rs6000 (rs6000-d.o): New rule.
	* config/s390/s390-d.c: New file.
	* config/s390/s390-protos.h (s390_d_target_versions): New prototype.
	* config/s390/s390.h (TARGET_D_CPU_VERSIONS): Define.
	* config/s390/t-s390 (s390-d.o): New rule.
	* config/sparc/sparc-d.c: New file.
	* config/sparc/sparc-protos.h (sparc_d_target_versions): New prototype.
	* config/sparc/sparc.h (TARGET_D_CPU_VERSIONS): Define.
	* config/sparc/t-sparc (sparc-d.o): New rule.
	* config/t-glibc (glibc-d.o): New rule.
	* gcc/configure.ac (tm_d_file): New variable.
	(tm_d_file_list, tm_d_include_list, d_target_objs): Add substitute.
	* gcc/configure: Regenerated. 
	* doc/tm.texi.in: Add @node for D language, and @hook for
	TARGET_D_CPU_VERSIONS, TARGET_D_OS_VERSIONS, and TARGET_D_CRITSEC_SIZE.
	* doc/tm.texi: Regenerated.
	* gcc/genhooks.c: Include d/d-target.def.

---
 gcc/Makefile.in   | 37 +++--
 gcc/config.gcc| 29 ++
 gcc/config/aarch64/aarch64-d.c| 31 +++
 gcc/config/aarch64/aarch64-linux.h|  2 +
 gcc/config/aarch64/aarch64-protos.h   |  3 ++
 gcc/config/aarch64/aarch64.h  |  3 ++
 gcc/config/aarch64/t-aarch64  |  4 ++
 gcc/config/arm/arm-d.c| 53 +++
 gcc/config/arm/arm-protos.h   |  3 ++
 gcc/config/arm/arm.h  |  3 ++
 gcc/config/arm/linux-eabi.h   |  3 ++
 gcc/config/arm/t-arm  |  4 ++
 gcc/config/default-d.c| 25 +
 gcc/config/glibc-d.c  

[PATCH 08/14] Add D2 Testsuite files.

2018-09-17 Thread Iain Buclaw
This patch adds part of the D2 testsuite, which includes D source code
files that are considered compilable; files that are considered
uncompilable, but should not ICE; and files that should execute on
targets with crash or assertion failures.

ftp://ftp.gdcproject.org/patches/v4/08-v4-d-testsuite.patch

---
 gcc/testsuite/gdc.test/compilable/99bottles.d |   52 +
 gcc/testsuite/gdc.test/compilable/a3682.d |   20 +
 .../gdc.test/compilable/aggr_alignment.d  |   28 +
 gcc/testsuite/gdc.test/compilable/aliasdecl.d |   40 +
 gcc/testsuite/gdc.test/compilable/alignment.d |   12 +
 gcc/testsuite/gdc.test/compilable/art4769.d   |   19 +
 gcc/testsuite/gdc.test/compilable/b8.d|   12 +
 gcc/testsuite/gdc.test/compilable/b1215.d |  146 +
 gcc/testsuite/gdc.test/compilable/b15428.d|   13 +
 gcc/testsuite/gdc.test/compilable/b16244.d|   12 +
 gcc/testsuite/gdc.test/compilable/b16346.d|3 +
 gcc/testsuite/gdc.test/compilable/b16355.d|   14 +
 gcc/testsuite/gdc.test/compilable/b16382.d|6 +
 gcc/testsuite/gdc.test/compilable/b16483.d|   12 +
 gcc/testsuite/gdc.test/compilable/b16598.d|   15 +
 gcc/testsuite/gdc.test/compilable/b16697.d|   13 +
 gcc/testsuite/gdc.test/compilable/b16967.d|   33 +
 gcc/testsuite/gdc.test/compilable/b17111.d|   13 +
 gcc/testsuite/gdc.test/compilable/b33.d   |   12 +
 gcc/testsuite/gdc.test/compilable/b6227.d |   18 +
 gcc/testsuite/gdc.test/compilable/b6395.d |   25 +
 gcc/testsuite/gdc.test/compilable/b6400.d |   37 +
 .../gdc.test/compilable/betterCarray.d|   17 +
 .../gdc.test/compilable/betterCswitch.d   |   16 +
 gcc/testsuite/gdc.test/compilable/bug11735.d  |   36 +
 gcc/testsuite/gdc.test/compilable/bug6963.d   |   73 +
 gcc/testsuite/gdc.test/compilable/callconv.d  |   75 +
 gcc/testsuite/gdc.test/compilable/compile1.d  |  964 ++
 gcc/testsuite/gdc.test/compilable/const.d |   41 +
 gcc/testsuite/gdc.test/compilable/cppmangle.d |  353 +
 gcc/testsuite/gdc.test/compilable/ctfe_math.d |   25 +
 gcc/testsuite/gdc.test/compilable/ddoc1.d |   69 +
 gcc/testsuite/gdc.test/compilable/ddoc10.d|  210 +
 gcc/testsuite/gdc.test/compilable/ddoc10236.d |   59 +
 .../gdc.test/compilable/ddoc10236b.d  |   69 +
 gcc/testsuite/gdc.test/compilable/ddoc10325.d |   17 +
 gcc/testsuite/gdc.test/compilable/ddoc10334.d |   29 +
 gcc/testsuite/gdc.test/compilable/ddoc10366.d |   20 +
 gcc/testsuite/gdc.test/compilable/ddoc10367.d |   28 +
 gcc/testsuite/gdc.test/compilable/ddoc10869.d |   27 +
 gcc/testsuite/gdc.test/compilable/ddoc10870.d |   10 +
 gcc/testsuite/gdc.test/compilable/ddoc11.d|   69 +
 gcc/testsuite/gdc.test/compilable/ddoc11479.d |   96 +
 gcc/testsuite/gdc.test/compilable/ddoc11511.d |   20 +
 gcc/testsuite/gdc.test/compilable/ddoc11823.d |7 +
 gcc/testsuite/gdc.test/compilable/ddoc12.d|   20 +
 gcc/testsuite/gdc.test/compilable/ddoc12706.d |9 +
 gcc/testsuite/gdc.test/compilable/ddoc12745.d |   25 +
 gcc/testsuite/gdc.test/compilable/ddoc13.d|   26 +
 gcc/testsuite/gdc.test/compilable/ddoc13270.d |   18 +
 gcc/testsuite/gdc.test/compilable/ddoc13502.d |   24 +
 gcc/testsuite/gdc.test/compilable/ddoc13645.d |9 +
 gcc/testsuite/gdc.test/compilable/ddoc14.d|   97 +
 gcc/testsuite/gdc.test/compilable/ddoc14383.d |   14 +
 gcc/testsuite/gdc.test/compilable/ddoc14413.d |   12 +
 gcc/testsuite/gdc.test/compilable/ddoc14633.d |   23 +
 gcc/testsuite/gdc.test/compilable/ddoc14778.d |   42 +
 gcc/testsuite/gdc.test/compilable/ddoc15475.d |   12 +
 gcc/testsuite/gdc.test/compilable/ddoc17697.d |   29 +
 gcc/testsuite/gdc.test/compilable/ddoc198.d   |   35 +
 gcc/testsuite/gdc.test/compilable/ddoc2.d |   42 +
 gcc/testsuite/gdc.test/compilable/ddoc2273.d  |   37 +
 gcc/testsuite/gdc.test/compilable/ddoc3.d |   71 +
 gcc/testsuite/gdc.test/compilable/ddoc4.d |   11 +
 gcc/testsuite/gdc.test/compilable/ddoc4162.d  |   17 +
 gcc/testsuite/gdc.test/compilable/ddoc4899.d  |   23 +
 gcc/testsuite/gdc.test/compilable/ddoc5.d |   31 +
 gcc/testsuite/gdc.test/compilable/ddoc5446.d  |   69 +
 gcc/testsuite/gdc.test/compilable/ddoc5446a.d |   15 +
 gcc/testsuite/gdc.test/compilable/ddoc5446b.d |6 +
 gcc/testsuite/gdc.test/compilable/ddoc6.d |   25 +
 gcc/testsuite/gdc.test/compilable/ddoc648.d   |   90 +
 gcc/testsuite/gdc.test/compilable/ddoc6491.d  |   14 +
 gcc/testsuite/gdc.test/compilable/ddoc7.d |   59 +
 gcc/testsuite/gdc.test/compilable/ddoc7555.d  |   53 +
 gcc/testsuite/gdc.test/compilable/ddoc7656.d  |   24 +
 gcc/testsuite/gdc.test/compilable/ddoc7715.d  |   16 +
 gcc/testsuite/gdc.test/compilable/ddoc7795.d  |   17 +
 gcc/testsuite/gdc.test/compilable/ddoc8.d |9 +
 gcc/testsuite/gdc.test/compilable/ddoc8271.d  |   15 +
 gcc/testsuite/gdc.test/compilable/ddoc8739.d  |   19 +
 gcc/testsuite/gdc.test/compilable/ddoc9.d |   26 +
 gcc/testsuite/gdc.test/compilable/ddoc9037.d  |   18 +
 gcc/testsuite/gdc.test/compilable/ddoc9

  1   2   3   4   5   6   7   8   9   10   >