Re: [PATCH, d] Committed merge with upstream dmd e9420cfbf

2020-03-19 Thread Iain Buclaw via Gcc-patches
On 15/03/2020 14:32, Rainer Orth wrote:
> Hi Ian,
> 
>> This patch merges the D front-end implementation with dmd upstream e9420cfbf.
> [...]
>> Bootstrapped and tested on x86_64-linux-gnu, and committed to trunk.
> 
> this merge introduced a regression on Solaris (SPARC and x86):
> 
> +UNRESOLVED: gdc.test/runnable/traits.d   compilation failed to produce 
> executable
> +UNRESOLVED: gdc.test/runnable/traits.d -shared-libphobos   compilation 
> failed to produce executable
> 
> runnable/traits.d:1256:23: error: statement expected to be { }, not (^M
> runnable/traits.d:1256:29: error: found 'out' when expecting ';' following 
> statement^M
> runnable/traits.d:1256:32: error: declaration expected, not '('^M
> runnable/traits.d:1256:38: error: no identifier for declarator r^M
> runnable/traits.d:1256:38: error: declaration expected, not '=='^M
> runnable/traits.d:1257:1: error: unrecognized declaration^M
> 
> I suspect the changes need to be moved to their own file in
> gdc.test/fail_compilation.
> 

The backported test used a newer syntax for contracts that's not in the C++ 
port of the D front-end.  I've amended this and committed the fix.

Iain.


[PATCH d]: Committed merge with upstream dmd

2020-03-16 Thread Iain Buclaw via Gcc-patches
Hi,

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

Fixes an ICE in the parser, and deprecates a previously allowed style of
syntax that deviated from GNU-style extended asm.

Bootstrapped and tested on x86_64-linux-gnu, and committed to trunk.

Regards
Iain.

---
gcc/testsuite/ChangeLog:

2020-03-16  Iain Buclaw  

* gdc.dg/asm1.d: Add new test for ICE in asm parser.
* gdc.dg/asm5.d: New test.

---
 gcc/d/dmd/MERGE |  2 +-
 gcc/d/dmd/iasmgcc.c | 30 +++---
 gcc/testsuite/ChangeLog |  5 +
 gcc/testsuite/gdc.dg/asm1.d |  9 +
 gcc/testsuite/gdc.dg/asm5.d | 12 
 5 files changed, 54 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/asm5.d

diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index b017c037d74..6cbc4e37819 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-e9420cfbf5cd0cf9e6e398603e009ccc8e14d324
+b061bd744cb4eb94a7118581387d988d4ec25e97
 
 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/iasmgcc.c b/gcc/d/dmd/iasmgcc.c
index cecbdefe41a..548453321db 100644
--- a/gcc/d/dmd/iasmgcc.c
+++ b/gcc/d/dmd/iasmgcc.c
@@ -13,6 +13,7 @@
 
 #include "scope.h"
 #include "declaration.h"
+#include "errors.h"
 #include "parse.h"
 #include "statement.h"
 
@@ -23,8 +24,8 @@ Statement *semantic(Statement *s, Scope *sc);
  * Parse list of extended asm input or output operands.
  * Grammar:
  *  | Operands:
- *  | SymbolicName(opt) StringLiteral AssignExpression
- *  | SymbolicName(opt) StringLiteral AssignExpression , Operands
+ *  | SymbolicName(opt) StringLiteral ( AssignExpression )
+ *  | SymbolicName(opt) StringLiteral ( AssignExpression ), Operands
  *  |
  *  | SymbolicName:
  *  | [ Identifier ]
@@ -54,7 +55,9 @@ static int parseExtAsmOperands(Parser *p, GccAsmStatement *s)
 case TOKlbracket:
 if (p->peekNext() == TOKidentifier)
 {
+// Skip over openings `[`
 p->nextToken();
+// Store the symbolic name
 name = p->token.ident;
 p->nextToken();
 }
@@ -63,12 +66,32 @@ static int parseExtAsmOperands(Parser *p, GccAsmStatement 
*s)
 p->error(s->loc, "expected identifier after `[`");
 goto Lerror;
 }
+// Look for closing `]`
 p->check(TOKrbracket);
+// Look for the string literal and fall through
+if (p->token.value != TOKstring)
+goto Ldefault;
 // fall through
 
 case TOKstring:
 constraint = p->parsePrimaryExp();
-arg = p->parseAssignExp();
+// @@@DEPRECATED@@@
+// Old parser allowed omitting parentheses around the 
expression.
+// Deprecated in 2.091. Can be made permanent error after 2.100
+if (p->token.value != TOKlparen)
+{
+arg = p->parseAssignExp();
+deprecation(arg->loc, "`%s` must be surrounded by 
parentheses", arg->toChars());
+}
+else
+{
+// Look for the opening `(`
+p->check(TOKlparen);
+// Parse the assign expression
+arg = p->parseAssignExp();
+// Look for the closing `)`
+p->check(TOKrparen);
+}
 
 if (!s->args)
 {
@@ -86,6 +109,7 @@ static int parseExtAsmOperands(Parser *p, GccAsmStatement *s)
 break;
 
 default:
+Ldefault:
 p->error("expected constant string constraint for operand, not 
`%s`",
 p->token.toChars());
 goto Lerror;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ab0406656d2..32a51b96a0e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-03-16  Iain Buclaw  
+
+   * gdc.dg/asm1.d: Add new test for ICE in asm parser.
+   * gdc.dg/asm5.d: New test.
+
 2020-03-16  Bin Cheng  
 
PR tree-optimization/94125
diff --git a/gcc/testsuite/gdc.dg/asm1.d b/gcc/testsuite/gdc.dg/asm1.d
index 7b00e4d54ec..3fcfd6a58c1 100644
--- a/gcc/testsuite/gdc.dg/asm1.d
+++ b/gcc/testsuite/gdc.dg/asm1.d
@@ -29,6 +29,15 @@ void parse3()
 // { dg-error "found 'EOF' when expecting ';'" "" { target *-*-* } .-4 }
 }
 
+void parse4()
+{
+int expr;
+asm
+{
+"%name" : [name] string (expr); // { dg-error "expected constant 
string constraint for operand, not 'string'" }
+}
+}
+
 void semantic1()
 {
 {
diff --git a/gcc/testsuite/gdc.dg/asm5.d 

Re: [PATCH, d] Committed merge with upstream dmd e9420cfbf

2020-03-15 Thread Rainer Orth
Hi Ian,

> This patch merges the D front-end implementation with dmd upstream e9420cfbf.
[...]
> Bootstrapped and tested on x86_64-linux-gnu, and committed to trunk.

this merge introduced a regression on Solaris (SPARC and x86):

+UNRESOLVED: gdc.test/runnable/traits.d   compilation failed to produce 
executable
+UNRESOLVED: gdc.test/runnable/traits.d -shared-libphobos   compilation failed 
to produce executable

runnable/traits.d:1256:23: error: statement expected to be { }, not (^M
runnable/traits.d:1256:29: error: found 'out' when expecting ';' following 
statement^M
runnable/traits.d:1256:32: error: declaration expected, not '('^M
runnable/traits.d:1256:38: error: no identifier for declarator r^M
runnable/traits.d:1256:38: error: declaration expected, not '=='^M
runnable/traits.d:1257:1: error: unrecognized declaration^M

I suspect the changes need to be moved to their own file in
gdc.test/fail_compilation.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


[PATCH, d] Committed merge with upstream dmd 375ed10aa

2019-08-21 Thread Iain Buclaw
Hi,

This patch merges the dmd frontend implementation with upstream dmd 375ed10aa.

This allows the frontend to be able to compile on targets where the
pointer size is 16-bits.

Bootstrapped and regression tested the D testsuite on
x86_64-linux-gnu, with further checking done on msp430-elf
cross-compiler target to verify that at least simple programs can be
compiled on 16-bit targets.

Committed to trunk as r274768.

--
Iain
---
gcc/d/ChangeLog:

* d-target.cc: Include diagnostic.h.
(Target::_init): Set Tsize_t and Tptrdiff_t as D ushort and short if
the target pointer size is 2.  Add sorry if the pointer size is not
either 2, 4, or 8.
---
diff --git a/gcc/d/d-target.cc b/gcc/d/d-target.cc
index 8d85534f054..dfaf9bf3792 100644
--- a/gcc/d/d-target.cc
+++ b/gcc/d/d-target.cc
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree.h"
 #include "memmodel.h"
 #include "fold-const.h"
+#include "diagnostic.h"
 #include "stor-layout.h"
 #include "tm.h"
 #include "tm_p.h"
@@ -145,17 +146,24 @@ Target::_init (void)
   Target::maxStaticDataSize = tree_to_shwi (TYPE_MAX_VALUE (integer_type_node));
 
   /* Define what type to use for size_t, ptrdiff_t.  */
-  if (POINTER_SIZE == 64)
+  if (Target::ptrsize == 8)
 {
   global.params.isLP64 = true;
   Tsize_t = Tuns64;
   Tptrdiff_t = Tint64;
 }
-  else
+  else if (Target::ptrsize == 4)
 {
   Tsize_t = Tuns32;
   Tptrdiff_t = Tint32;
 }
+  else if (Target::ptrsize == 2)
+{
+  Tsize_t = Tuns16;
+  Tptrdiff_t = Tint16;
+}
+  else
+sorry ("D does not support pointers on this target.");
 
   Type::tsize_t = Type::basic[Tsize_t];
   Type::tptrdiff_t = Type::basic[Tptrdiff_t];
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index d208aea3717..cb7b6bfac7f 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-792f0fdf249b21531dc91690024827f4f9ecbb97
+375ed10aa7eb28755f92775ca5c5399550cd100b
 
 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/expression.c b/gcc/d/dmd/expression.c
index c674392095e..5f1bfa8f5a9 100644
--- a/gcc/d/dmd/expression.c
+++ b/gcc/d/dmd/expression.c
@@ -2920,10 +2920,12 @@ void IntegerExp::normalize()
 case Tint64:value = (d_int64) value;break;
 case Tuns64:value = (d_uns64) value;break;
 case Tpointer:
-if (Target::ptrsize == 4)
-value = (d_uns32) value;
-else if (Target::ptrsize == 8)
+if (Target::ptrsize == 8)
 value = (d_uns64) value;
+else if (Target::ptrsize == 4)
+value = (d_uns32) value;
+else if (Target::ptrsize == 2)
+value = (d_uns16) value;
 else
 assert(0);
 break;
diff --git a/gcc/d/dmd/hdrgen.c b/gcc/d/dmd/hdrgen.c
index 4eaa1ae1050..395aa3212b5 100644
--- a/gcc/d/dmd/hdrgen.c
+++ b/gcc/d/dmd/hdrgen.c
@@ -2152,10 +2152,12 @@ public:
 if ((sinteger_t)uval >= 0)
 {
 dinteger_t sizemax;
-if (Target::ptrsize == 4)
-sizemax = 0xUL;
-else if (Target::ptrsize == 8)
+if (Target::ptrsize == 8)
 sizemax = 0xULL;
+else if (Target::ptrsize == 4)
+sizemax = 0xUL;
+else if (Target::ptrsize == 2)
+sizemax = 0xUL;
 else
 assert(0);
 if (uval <= sizemax && uval <= 0x7FFFULL)
@@ -2296,12 +2298,10 @@ public:
 buf->writestring("cast(");
 buf->writestring(t->toChars());
 buf->writeByte(')');
-if (Target::ptrsize == 4)
-goto L3;
-else if (Target::ptrsize == 8)
+if (Target::ptrsize == 8)
 goto L4;
 else
-assert(0);
+goto L3;
 
 default:
 /* This can happen if errors, such as


[PATCH, d] Committed merge with upstream dmd 6e44734cc

2019-06-16 Thread Iain Buclaw
Hi,

This patch merges the dmd frontend implementation with upstream dmd
6e44734cc, and the libdruntime sub-directory with upstream druntime
cb1583b4.

The patch has been split up into separate commits, so that all PRs
fixed are individually referenced with the part of the patch that
addresses that issue.

Listing the PRs in numerical order.

PR d/90559  (r272351)
PR d/90560  (r272348)
PR d/90650  (r272344)
PR d/90651  (r272345)
PR d/90602  (r272342)
PR d/90604  (r272343)
PR d/90651  (r272340)
PR d/90660  (r272339)
PR d/90661  (r272341)
PR d/90761  (r272346)
PR d/90762  (r272347)
PR d/90863  (r272352)

Bootstrapped and regression tested on x86_64-linux-gnu.

Committed to trunk.

-- 
Iain
---
2019-06-16  Iain Buclaw  

gcc/d/ChangeLog:
PR d/90559
* d-target.cc (Target::_init): Reduce max static data size to INT_MAX.

PR d/90651
* typeinfo.cc (object_module): New variable.
(make_frontend_typeinfo): Update signature.  Set temporary on
generated TypeInfo classes.
(create_tinfo_types): Set object_module.  Move generation of front-end
typeinfo into ...
(create_frontend_tinfo_types): ... New function.
(layout_typeinfo): Call create_frontend_tinfo_types.
(layout_classinfo): Likewise.
(layout_cpp_typeinfo): Likewise.
(create_typeinfo): Likewise.

gcc/testsuite/ChangeLog:
PR d/90650
* gdc.dg/pr90650a.d: New test.
* gdc.dg/pr90650b.d: New test.

---
commit b5e4c44129acca5d6958c06b0ad6754f8a3763fc

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272352 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 4111fc97044..0620a5ba556 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-7afcc60c30554e452eacdfbefc4951ebf601fccd
+6e44734ccbeb78252a52e129a67fefb313679948
 
 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/blockexit.c b/gcc/d/dmd/blockexit.c
index e9d3f105429..c3b60b88216 100644
--- a/gcc/d/dmd/blockexit.c
+++ b/gcc/d/dmd/blockexit.c
@@ -496,6 +496,8 @@ int blockExit(Statement *s, FuncDeclaration *func, bool mustNotThrow)
 }
 };
 
+if (!s)
+return BEfallthru;
 BlockExit be(func, mustNotThrow);
 s->accept();
 return be.result;
diff --git a/gcc/d/dmd/statementsem.c b/gcc/d/dmd/statementsem.c
index 167836c0478..143864dc666 100644
--- a/gcc/d/dmd/statementsem.c
+++ b/gcc/d/dmd/statementsem.c
@@ -2035,7 +2035,7 @@ public:
 ss->_body = semantic(ss->_body, sc);
 sc->noctor--;
 
-if (conditionError || ss->_body->isErrorStatement())
+if (conditionError || (ss->_body && ss->_body->isErrorStatement()))
 goto Lerror;
 
 // Resolve any goto case's with exp
@@ -2111,7 +2111,7 @@ public:
 {
 ss->hasNoDefault = 1;
 
-if (!ss->isFinal && !ss->_body->isErrorStatement())
+if (!ss->isFinal && (!ss->_body || !ss->_body->isErrorStatement()))
 ss->error("switch statement without a default; use 'final switch' or add 'default: assert(0);' or add 'default: break;'");
 
 // Generate runtime error if the default is hit
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail19955.d b/gcc/testsuite/gdc.test/fail_compilation/fail19955.d
new file mode 100644
index 000..7cdce2c676a
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail19955.d
@@ -0,0 +1,8 @@
+// PERMUTE_ARGS:
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail19955.d(8): Error: `switch` statement without a `default`; use `final switch` or add `default: assert(0);` or add `default: break;`
+---
+*/
+void f() { switch(1) static assert(1); }

commit 960d7913321bce56e4cb16c38500f6c8b1291853

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272351 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/d/d-target.cc b/gcc/d/d-target.cc
index e0cfbafe0b9..8d85534f054 100644
--- a/gcc/d/d-target.cc
+++ b/gcc/d/d-target.cc
@@ -140,8 +140,9 @@ Target::_init (void)
   /* Size of run-time TypeInfo object.  */
   Target::classinfosize = 19 * Target::ptrsize;
 
-  /* Allow data sizes up to half of the address space.  */
-  Target::maxStaticDataSize = tree_to_shwi (TYPE_MAX_VALUE (ptrdiff_type_node));
+  /* Much of the dmd front-end uses ints for sizes and offsets, and cannot
+ handle any larger data type without some pervasive rework.  */
+  Target::maxStaticDataSize = tree_to_shwi (TYPE_MAX_VALUE (integer_type_node));
 
   /* Define what type to use for size_t, ptrdiff_t.  */
   if (POINTER_SIZE == 64)
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 01c8cb0325d..4111fc97044 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-f8e38c001b9d7bd6586ee5b3dab7f7f199a69be7
+7afcc60c30554e452eacdfbefc4951ebf601fccd
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.

[PATCH, d] Committed merge with upstream dmd

2019-04-12 Thread Iain Buclaw
Hi,

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

Adds new virtual isVersionCondition, this is so that in the code
generation pass, a ConditionDeclaration's condition can be identified
without requiring a Visitor function.

Bootstrapped and regression tested on x86_64-linux-gnu.

Committed to trunk as r270300.

-- 
Iain
---
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 800be95e4e6..be0c5a50da2 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-d7ed327edb0b01ad56e7e73e77b3401cd565675e
+c185f9df1789456c7d88d047f2df23dd784f1182
 
 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/cond.h b/gcc/d/dmd/cond.h
index 891969be48d..8e33b16a9da 100644
--- a/gcc/d/dmd/cond.h
+++ b/gcc/d/dmd/cond.h
@@ -39,6 +39,7 @@ public:
 virtual Condition *syntaxCopy() = 0;
 virtual int include(Scope *sc, ScopeDsymbol *sds) = 0;
 virtual DebugCondition *isDebugCondition() { return NULL; }
+virtual VersionCondition *isVersionCondition() { return NULL; }
 virtual void accept(Visitor *v) { v->visit(this); }
 };
 
@@ -91,6 +92,7 @@ public:
 VersionCondition(Module *mod, unsigned level, Identifier *ident);
 
 int include(Scope *sc, ScopeDsymbol *sds);
+VersionCondition *isVersionCondition() { return this; }
 void accept(Visitor *v) { v->visit(this); }
 };
 


[PATCH, d] Committed merge with upstream dmd

2019-04-11 Thread Iain Buclaw
Hi,

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

Backports fix for an ICE that occurred when accessing empty array in CTFE.

Bootstrapped and regression tested on x86_64-linux-gnu.

Committed to trunk as r270294.

-- 
Iain
---
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 31ea106965b..800be95e4e6 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-5dd3eccc3b0758346f77bee3cdc3f6bd15de339b
+d7ed327edb0b01ad56e7e73e77b3401cd565675e
 
 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/dinterpret.c b/gcc/d/dmd/dinterpret.c
index 777f89cf186..40f3e77cbc5 100644
--- a/gcc/d/dmd/dinterpret.c
+++ b/gcc/d/dmd/dinterpret.c
@@ -6272,11 +6272,14 @@ Expression *scrubReturnValue(Loc loc, Expression *e)
 /* Returns: true if e is void,
  * or is an array literal or struct literal of void elements.
  */
-static bool isVoid(Expression *e)
+static bool isVoid(Expression *e, bool checkArray = false)
 {
 if (e->op == TOKvoid)
 return true;
 
+if (checkArray && e->type->ty != Tsarray)
+return false;
+
 if (e->op == TOKarrayliteral)
 return isEntirelyVoid(((ArrayLiteralExp *)e)->elements);
 
@@ -6314,7 +6317,7 @@ Expression *scrubArray(Loc loc, Expressions *elems, bool structlit)
 
 // A struct .init may contain void members.
 // Static array members are a weird special case (bug 10994).
-if (structlit && isVoid(e))
+if (structlit && isVoid(e, true))
 {
 e = NULL;
 }
diff --git a/gcc/testsuite/gdc.test/compilable/test19778.d b/gcc/testsuite/gdc.test/compilable/test19778.d
new file mode 100644
index 000..87905fae6a0
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test19778.d
@@ -0,0 +1,6 @@
+struct S
+{
+int[] data;
+}
+immutable X = S([]);
+enum len = X.data.length;


[PATCH, d] Committed merge with upstream dmd

2019-03-30 Thread Iain Buclaw
Hi,

The patch merges the D front-end implementation with dmd upstream 5dd3eccc3.

Aligns the test flags between gcc and upstream, after adding support
to gdc-test.exp to handle extra source and file settings being passed
multiple times.

Regression tested on x86_64-linux-gnu.

Committed to trunk as r270038.

-- 
Iain
---
gcc/testsuite/ChangeLog:

2019-03-30  Iain Buclaw  

* gdc.test/gdc-test.exp (gdc-copy-extra): Append copied files to
cleanup_extra_files.
(dmd2dg): Copy additional files after test is translated.
(gdc-do-test): Remove all copied files after test.

---
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index ffad6cb524d..31ea106965b 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-ab702e73e56aefb3b77b8f8f42da94bc22143eeb
+5dd3eccc3b0758346f77bee3cdc3f6bd15de339b
 
 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/testsuite/gdc.test/compilable/test6395.d b/gcc/testsuite/gdc.test/compilable/test6395.d
index 95f1a7eae6e..a1bac8e48f1 100644
--- a/gcc/testsuite/gdc.test/compilable/test6395.d
+++ b/gcc/testsuite/gdc.test/compilable/test6395.d
@@ -1,5 +1,6 @@
-// REQUIRED_ARGS: -c -Icompilable/extra-files
+// REQUIRED_ARGS: -Icompilable/extra-files
 // EXTRA_SOURCES: b6395.d
+// EXTRA_FILES: extra-files/c6395.d
 
 // 6395
 
diff --git a/gcc/testsuite/gdc.test/compilable/test7190.d b/gcc/testsuite/gdc.test/compilable/test7190.d
index 5143f55e772..45344f13b8f 100644
--- a/gcc/testsuite/gdc.test/compilable/test7190.d
+++ b/gcc/testsuite/gdc.test/compilable/test7190.d
@@ -1,6 +1,9 @@
 // PERMUTE_ARGS:
 // REQUIRED_ARGS: -Icompilable/extra-files
-// EXTRA_FILES: extra-files/example7190/controllers/HomeController.d extra-files/example7190/models/HomeModel.d extra-files/serenity7190/core/Controller.d  extra-files/serenity7190/core/Model.d
+// EXTRA_FILES: extra-files/example7190/controllers/HomeController.d
+// EXTRA_FILES: extra-files/example7190/models/HomeModel.d
+// EXTRA_FILES: extra-files/serenity7190/core/Controller.d
+// EXTRA_FILES: extra-files/serenity7190/core/Model.d
 
 import example7190.controllers.HomeController;
 import example7190.models.HomeModel;
diff --git a/gcc/testsuite/gdc.test/compilable/test9436.d b/gcc/testsuite/gdc.test/compilable/test9436.d
index c80bdc59e82..2baee7c216b 100644
--- a/gcc/testsuite/gdc.test/compilable/test9436.d
+++ b/gcc/testsuite/gdc.test/compilable/test9436.d
@@ -1,4 +1,3 @@
-// REQUIRED_ARGS: -c
 // EXTRA_SOURCES: imports/test9436interp.d
 
 // this is a dummy module for test 9436.
diff --git a/gcc/testsuite/gdc.test/compilable/testDIP37.d b/gcc/testsuite/gdc.test/compilable/testDIP37.d
index a612365eaf4..7188758414c 100644
--- a/gcc/testsuite/gdc.test/compilable/testDIP37.d
+++ b/gcc/testsuite/gdc.test/compilable/testDIP37.d
@@ -1,6 +1,9 @@
 // PERMUTE_ARGS:
 // REQUIRED_ARGS: -Icompilable/extra-files
-// EXTRA_FILES: extra-files/pkgDIP37/datetime/package.d extra-files/pkgDIP37/datetime/common.d extra-files/pkgDIP37/test17629/package.di extra-files/pkgDIP37/test17629/common.di
+// EXTRA_FILES: extra-files/pkgDIP37/datetime/package.d
+// EXTRA_FILES: extra-files/pkgDIP37/datetime/common.d
+// EXTRA_FILES: extra-files/pkgDIP37/test17629/package.di
+// EXTRA_FILES: extra-files/pkgDIP37/test17629/common.di
 
 void test1()
 {
diff --git a/gcc/testsuite/gdc.test/compilable/testDIP37_10302.d b/gcc/testsuite/gdc.test/compilable/testDIP37_10302.d
index 7e76595f06f..3c4a409b709 100644
--- a/gcc/testsuite/gdc.test/compilable/testDIP37_10302.d
+++ b/gcc/testsuite/gdc.test/compilable/testDIP37_10302.d
@@ -1,6 +1,7 @@
 // PERMUTE_ARGS:
-// REQUIRED_ARGS: -c -Icompilable/extra-files
-// EXTRA_SOURCES: extra-files/pkgDIP37_10302/liba.d extra-files/pkgDIP37_10302/libb.d
+// REQUIRED_ARGS: -Icompilable/extra-files
+// COMPILED_IMPORTS: extra-files/pkgDIP37_10302/liba.d
+// COMPILED_IMPORTS: extra-files/pkgDIP37_10302/libb.d
 // EXTRA_FILES: extra-files/pkgDIP37_10302/package.d
 
 module test;
diff --git a/gcc/testsuite/gdc.test/compilable/testDIP37_10354.d b/gcc/testsuite/gdc.test/compilable/testDIP37_10354.d
index 2993fa94d39..f9adf86307c 100644
--- a/gcc/testsuite/gdc.test/compilable/testDIP37_10354.d
+++ b/gcc/testsuite/gdc.test/compilable/testDIP37_10354.d
@@ -1,6 +1,8 @@
 // PERMUTE_ARGS:
 // REQUIRED_ARGS: -o- -Icompilable/extra-files
-// EXTRA_FILES: extra-files/pkgDIP37_10354/mbar.d extra-files/pkgDIP37_10354/mfoo.d extra-files/pkgDIP37_10354/package.d
+// EXTRA_FILES: extra-files/pkgDIP37_10354/mbar.d
+// EXTRA_FILES: extra-files/pkgDIP37_10354/mfoo.d
+// EXTRA_FILES: extra-files/pkgDIP37_10354/package.d
 
 module testDIP37_10354;
 import pkgDIP37_10354.mfoo;
diff --git a/gcc/testsuite/gdc.test/compilable/testDIP37_10421.d b/gcc/testsuite/gdc.test/compilable/testDIP37_10421.d
index 859347331b1..7da5bcf2d08 100644
--- a/gcc/testsuite/gdc.test/compilable/testDIP37_10421.d
+++ b/gcc/testsuite/gdc.test/compilable/testDIP37_10421.d
@@ -1,6 

[PATCH, d] Committed merge with upstream dmd

2019-03-26 Thread Iain Buclaw
Hi,

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

Backports memory leak fix in the mangler, and introduces recognition
and rejection of more C types and directives.

Bootstrapped and regression tested on x86_64-linux-gnu.

Committed to trunk as r269945.

-- 
Iain
---
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 3017f0d34af..ffad6cb524d 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-74ac873be1862090b7ec0e4a876fd1b758520359
+ab702e73e56aefb3b77b8f8f42da94bc22143eeb
 
 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/dmangle.c b/gcc/d/dmd/dmangle.c
index 7f13947ae2b..44f4f826b41 100644
--- a/gcc/d/dmd/dmangle.c
+++ b/gcc/d/dmd/dmangle.c
@@ -306,8 +306,9 @@ public:
 buf2.reserve(32);
 Mangler v();
 v.paramsToDecoBuffer(t->arguments);
+const char *s = buf2.peekString();
 int len = (int)buf2.offset;
-buf->printf("%d%.*s", len, len, buf2.extractData());
+buf->printf("%d%.*s", len, len, s);
 }
 
 void visit(TypeNull *t)
diff --git a/gcc/d/dmd/dscope.c b/gcc/d/dmd/dscope.c
index 27c3fd58947..def448a2408 100644
--- a/gcc/d/dmd/dscope.c
+++ b/gcc/d/dmd/dscope.c
@@ -685,14 +685,16 @@ Dsymbol *Scope::search_correct(Identifier *ident)
 const char *Scope::search_correct_C(Identifier *ident)
 {
 TOK tok;
-if (ident == Id::_NULL)
+if (ident == Id::C_NULL)
 tok = TOKnull;
-else if (ident == Id::_TRUE)
+else if (ident == Id::C_TRUE)
 tok = TOKtrue;
-else if (ident == Id::_FALSE)
+else if (ident == Id::C_FALSE)
 tok = TOKfalse;
-else if (ident == Id::_unsigned)
+else if (ident == Id::C_unsigned)
 tok = TOKuns32;
+else if (ident == Id::C_wchar_t)
+tok = global.params.isWindows ? TOKwchar : TOKdchar;
 else
 return NULL;
 return Token::toChars(tok);
diff --git a/gcc/d/dmd/idgen.c b/gcc/d/dmd/idgen.c
index ec26b2c7008..e75004893aa 100644
--- a/gcc/d/dmd/idgen.c
+++ b/gcc/d/dmd/idgen.c
@@ -374,10 +374,11 @@ Msgtable msgtable[] =
 { "udaSelector", "selector" },
 
 // C names, for undefined identifier error messages
-{ "_NULL", "NULL" },
-{ "_TRUE", "TRUE" },
-{ "_FALSE", "FALSE" },
-{ "_unsigned", "unsigned" },
+{ "C_NULL", "NULL" },
+{ "C_TRUE", "TRUE" },
+{ "C_FALSE", "FALSE" },
+{ "C_unsigned", "unsigned" },
+{ "C_wchar_t", "wchar_t" },
 };
 
 
diff --git a/gcc/d/dmd/lexer.c b/gcc/d/dmd/lexer.c
index b466f17e4be..8a2c90f1dfd 100644
--- a/gcc/d/dmd/lexer.c
+++ b/gcc/d/dmd/lexer.c
@@ -901,16 +901,25 @@ void Lexer::scan(Token *t)
 p++;
 Token n;
 scan();
-if (n.value == TOKidentifier && n.ident == Id::line)
+if (n.value == TOKidentifier)
 {
-poundLine();
-continue;
+   if (n.ident == Id::line)
+   {
+   poundLine();
+   continue;
+   }
+   else
+   {
+   const Loc locx = loc();
+   warning(locx, "C preprocessor directive `#%s` is not supported", n.ident->toChars());
+   }
 }
-else
+else if (n.value == TOKif)
 {
-t->value = TOKpound;
-return;
+error("C preprocessor directive `#if` is not supported, use `version` or `static if`");
 }
+t->value = TOKpound;
+return;
 }
 
 default:
diff --git a/gcc/d/dmd/parse.c b/gcc/d/dmd/parse.c
index e0ee299eb6d..3afdbc257f8 100644
--- a/gcc/d/dmd/parse.c
+++ b/gcc/d/dmd/parse.c
@@ -3076,7 +3076,23 @@ Type *Parser::parseBasicType(bool dontLookDotIdents)
 case TOKuns16:   t = Type::tuns16; goto LabelX;
 case TOKint32:   t = Type::tint32; goto LabelX;
 case TOKuns32:   t = Type::tuns32; goto LabelX;
-case TOKint64:   t = Type::tint64; goto LabelX;
+case TOKint64:
+t = Type::tint64;
+nextToken();
+if (token.value == TOKint64)// if `long long`
+{
+error("use `long` for a 64 bit integer instead of `long long`");
+nextToken();
+}
+else if (token.value == TOKfloat64) // if `long double`
+{
+error("use `real` instead of `long double`");
+t = Type::tfloat80;
+nextToken();
+
+}
+break;
+
 case TOKuns64:   t = Type::tuns64; goto LabelX;
 case TOKint128:  t = Type::tint128; goto LabelX;
 case TOKuns128:  t = Type::tuns128; goto LabelX;
diff --git a/gcc/testsuite/gdc.test/fail_compilation/cerrors.d 

[PATCH, d] Committed merge with upstream dmd

2019-03-12 Thread Iain Buclaw
Hi,

This patch merges the D front-end implementation with dmd upstream 7423993c9.

Backports a fix for extern(C++) mangling for substituted basic types
that are target-specific.  Introduces a new method that currently does
nothing, but could in future make use of flag_abi_version as
extern(C++) integration improves in latter versions of the D
front-end.

Bootstrapped and regression tested on x86_64-linux-gnu.

Committed to trunk as r269611.

-- 
Iain
---
gcc/d/ChangeLog:

2019-03-12  Iain Buclaw  

* d-lang.cc (d_init_options): Set global.params.cplusplus to C++14.
* d-target.cc (Target::cppFundamentalType): New method.
---
diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index b53e56e65a2..d97525a590e 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -282,6 +282,9 @@ d_init_options (unsigned int, cl_decoded_option *decoded_options)
   global.params.betterC = false;
   global.params.allInst = false;
 
+  /* Default extern(C++) mangling to C++14.  */
+  global.params.cplusplus = CppStdRevisionCpp14;
+
   global.params.linkswitches = new Strings ();
   global.params.libfiles = new Strings ();
   global.params.objfiles = new Strings ();
diff --git a/gcc/d/d-target.cc b/gcc/d/d-target.cc
index de57d9256db..e0cfbafe0b9 100644
--- a/gcc/d/d-target.cc
+++ b/gcc/d/d-target.cc
@@ -385,6 +385,15 @@ Target::cppParameterType (Parameter *arg)
   return t;
 }
 
+/* Checks whether TYPE is a vendor-specific fundamental type.  Stores the result
+   in IS_FUNDAMENTAL and returns true if the parameter was set.  */
+
+bool
+Target::cppFundamentalType (const Type *, bool &)
+{
+  return false;
+}
+
 /* Return the default system linkage for the target.  */
 
 LINK
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index cf5a22f070f..f58b620d844 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-fcc235e8e25f7758266f7874edd5abefb9943e0b
+7423993c996ed9f73d6ba6d58f625ad3c778ca1d
 
 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/cppmangle.c b/gcc/d/dmd/cppmangle.c
index b991417c35e..9b24fd2c2e4 100644
--- a/gcc/d/dmd/cppmangle.c
+++ b/gcc/d/dmd/cppmangle.c
@@ -120,6 +120,40 @@ class CppMangleVisitor : public Visitor
 !getQualifier(s));  // at global level
 }
 
+/
+ * Determine if type is a C++ fundamental type.
+ * Params:
+ *  t = type to check
+ * Returns:
+ *  true if it is a fundamental type
+ */
+static bool isFundamentalType(Type *t)
+{
+// First check the target whether some specific ABI is being followed.
+bool isFundamental;
+if (Target::cppFundamentalType(t, isFundamental))
+return isFundamental;
+if (t->ty == Tenum)
+{
+// Peel off enum type from special types.
+TypeEnum *te = (TypeEnum *)t;
+if (te->sym->isSpecial())
+t = te->sym->getMemtype(Loc());
+}
+
+// Fundamental arithmetic types:
+// 1. integral types: bool, char, int, ...
+// 2. floating point types: float, double, real
+// 3. void
+// 4. null pointer: std::nullptr_t (since C++11)
+if (t->ty == Tvoid || t->ty == Tbool)
+return true;
+else if (t->ty == Tnull && global.params.cplusplus >= CppStdRevisionCpp11)
+return true;
+else
+return t->isTypeBasic() && (t->isintegral() || t->isreal());
+}
+
 /**
  * Write the mangled representation of the template arguments.
  * Params:
@@ -741,7 +775,8 @@ public:
  */
 void writeBasicType(Type *t, char p, char c)
 {
-if (p || t->isConst())
+// Only do substitutions for non-fundamental types.
+if (!isFundamentalType(t) || t->isConst())
 {
 if (substitute(t))
 return;
@@ -767,6 +802,22 @@ public:
 if (t->isImmutable() || t->isShared())
 return error(t);
 
+// Handle any target-specific basic types.
+if (const char *tm = Target::cppTypeMangle(t))
+{
+// Only do substitutions for non-fundamental types.
+if (!isFundamentalType(t) || t->isConst())
+{
+if (substitute(t))
+return;
+else
+append(t);
+}
+CV_qualifiers(t);
+buf->writestring(tm);
+return;
+}
+
 /* :
  * vvoid
  * wwchar_t
@@ -832,17 +883,6 @@ public:
 case Tcomplex80:p = 'C'; c = 'e';   break;
 
 default:
-// Handle any target-specific basic types.
-if (const char *tm = Target::cppTypeMangle(t))
-{
-if (substitute(t))
-return;
-else
-

[PATCH, d] Committed merge with upstream dmd

2019-03-01 Thread Iain Buclaw
Hi,

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

Backports support for extern(C++, "namespace"), which makes the
core.stdcpp package compilable.

Added predefined condition for CppRuntime_Gcc unconditionally, as it
is unlikely that D code will be linking to anything other than
libstdc++ when extern(C++) is used.

Bootstrapped and regression tested on x86_64-linux-gnu.

Committed to trunk as r269304.

-- 
Iain
---

gcc/d/ChangeLog:

2019-03-01  Iain Buclaw  

* d-builtins.cc (d_init_versions): Add CppRuntime_Gcc as predefined
version condition.

---
diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc
index b0a315a3ed9..f263aafbd59 100644
--- a/gcc/d/d-builtins.cc
+++ b/gcc/d/d-builtins.cc
@@ -452,6 +452,8 @@ d_init_versions (void)
   /* Emit all target-specific version identifiers.  */
   targetdm.d_cpu_versions ();
   targetdm.d_os_versions ();
+
+  VersionCondition::addPredefinedGlobalIdent ("CppRuntime_Gcc");
 }
 
 /* A helper for d_build_builtins_module.  Return a new ALIAS for TYPE.
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 8b377015129..97aa40d1ace 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-39edbe17e7b5c761d780c9d1d4376a06df7bf3d8
+ed71446aaa2bd0e548c3bf2154a638826dfe3db0
 
 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/cond.c b/gcc/d/dmd/cond.c
index 8df226fa9b6..9d7df5fd240 100644
--- a/gcc/d/dmd/cond.c
+++ b/gcc/d/dmd/cond.c
@@ -171,6 +171,8 @@ static bool isReserved(const char *ident)
 "SysV4",
 "Hurd",
 "Android",
+"PlayStation",
+"PlayStation4",
 "Cygwin",
 "MinGW",
 "FreeStanding",
@@ -197,8 +199,11 @@ static bool isReserved(const char *ident)
 "MIPS_EABI",
 "MIPS_SoftFloat",
 "MIPS_HardFloat",
+"MSP430",
 "NVPTX",
 "NVPTX64",
+"RISCV32",
+"RISCV64",
 "SPARC",
 "SPARC_V8Plus",
 "SPARC_SoftFloat",
@@ -219,6 +224,13 @@ static bool isReserved(const char *ident)
 "CRuntime_Digitalmars",
 "CRuntime_Glibc",
 "CRuntime_Microsoft",
+"CRuntime_Musl",
+"CRuntime_UClibc",
+"CppRuntime_Clang",
+"CppRuntime_DigitalMars",
+"CppRuntime_Gcc",
+"CppRuntime_Microsoft",
+"CppRuntime_Sun",
 "D_Coverage",
 "D_Ddoc",
 "D_InlineAsm_X86",
diff --git a/gcc/d/dmd/cppmangle.c b/gcc/d/dmd/cppmangle.c
index e26f7647d3c..b991417c35e 100644
--- a/gcc/d/dmd/cppmangle.c
+++ b/gcc/d/dmd/cppmangle.c
@@ -196,8 +196,8 @@ class CppMangleVisitor : public Visitor
 Expression *e = isExpression(o);
 if (d && d->isFuncDeclaration())
 {
-bool is_nested = d->toParent() &&
-!d->toParent()->isModule() &&
+bool is_nested = d->toParent3() &&
+!d->toParent3()->isModule() &&
 ((TypeFunction*)d->isFuncDeclaration()->type)->linkage == LINKcpp;
 if (is_nested)
 buf->writeByte('X');
@@ -271,7 +271,7 @@ class CppMangleVisitor : public Visitor
  */
 Dsymbol *getInstance(Dsymbol *s)
 {
-Dsymbol *p = s->toParent();
+Dsymbol *p = s->toParent3();
 if (p)
 {
 if (TemplateInstance *ti = p->isTemplateInstance())
@@ -292,7 +292,7 @@ class CppMangleVisitor : public Visitor
  */
 static Dsymbol *getQualifier(Dsymbol *s)
 {
-Dsymbol *p = s->toParent();
+Dsymbol *p = s->toParent3();
 return (p && !p->isModule()) ? p : NULL;
 }
 
@@ -324,7 +324,7 @@ class CppMangleVisitor : public Visitor
 Dsymbol *s = ((TypeStruct*)t)->toDsymbol(NULL);
 if (s->ident != ident)
 return false;
-Dsymbol *p = s->toParent();
+Dsymbol *p = s->toParent3();
 if (!p)
 return false;
 TemplateInstance *ti = p->isTemplateInstance();
@@ -427,7 +427,7 @@ class CppMangleVisitor : public Visitor
 void cpp_mangle_name(Dsymbol *s, bool qualified)
 {
 //printf("cpp_mangle_name(%s, %d)\n", s->toChars(), qualified);
-Dsymbol *p = s->toParent();
+Dsymbol *p = s->toParent3();
 Dsymbol *se = s;
 bool write_prefix = true;
 if (p && p->isTemplateInstance())
@@ -435,7 +435,7 @@ class CppMangleVisitor : public Visitor
 se = p;
 if (find(p->isTemplateInstance()->tempdecl) >= 0)
 write_prefix = false;
-p = p->toParent();
+p = p->toParent3();
 }
 
 if (p && !p->isModule())
@@ -521,7 +521,7 @@ class CppMangleVisitor : public Visitor
 fatal();
 }
 
-Dsymbol *p = d->toParent();
+Dsymbol *p = d->toParent3();
 if (p && !p->isModule()) //for 

Re: [PATCH, d] Committed merge with upstream dmd

2019-01-22 Thread Iain Buclaw
On Tue, 22 Jan 2019 at 11:08, Andreas Schwab  wrote:
>
> In file included from ../../gcc/d/d-system.h:23,
>  from ../../gcc/d/dmd/root/dsystem.h:24,
>  from ../../gcc/d/dmd/mtype.c:11:
> ../../gcc/d/dmd/mtype.c: In member function 'Identifier* 
> Type::getTypeInfoIdent()':
> ../../gcc/d/dmd/mtype.c:2329:33: error: comparison of integer expressions of 
> different signedness: 'int' and 'size_t' {aka 'long unsigned int'} 
> [-Werror=sign-compare]
>  2329 | assert(0 < length && length < namelen); // don't overflow the 
> buffer
>   |  ~~~^
> ../../gcc/system.h:742:14: note: in definition of macro 'gcc_assert'
>   742 |((void)(!(EXPR) ? fancy_abort (__FILE__, __LINE__, __FUNCTION__), 
> 0 : 0))
>   |  ^~~~
> ../../gcc/d/dmd/mtype.c:2329:5: note: in expansion of macro 'assert'
>  2329 | assert(0 < length && length < namelen); // don't overflow the 
> buffer
>   | ^~
>

Sorry that slipped through.  Fix has gone in upstream and I'll commit it now.

-- 
Iain
---

diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index e8ab8df4f7b..c1c6cc145c4 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-180465274b72a2ff218449f6793af0fbaabbcaa3
+e21c07e84bd9668e1c0fc1f45e514c5fd76988e7

 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/mtype.c b/gcc/d/dmd/mtype.c
index 09161a313ee..2a23cab74fd 100644
--- a/gcc/d/dmd/mtype.c
+++ b/gcc/d/dmd/mtype.c
@@ -2326,7 +2326,7 @@ Identifier *Type::getTypeInfoIdent()

 int length = sprintf(name, "_D%lluTypeInfo_%s6__initZ", (unsigned
long long) 9 + len, buf.data);
 //printf("%p, deco = %s, name = %s\n", this, deco, name);
-assert(0 < length && length < namelen); // don't overflow the buffer
+assert(0 < length && (size_t)length < namelen); // don't
overflow the buffer

 Identifier *id = Identifier::idPool(name, length);


Re: [PATCH, d] Committed merge with upstream dmd

2019-01-22 Thread Andreas Schwab
In file included from ../../gcc/d/d-system.h:23,
 from ../../gcc/d/dmd/root/dsystem.h:24,
 from ../../gcc/d/dmd/mtype.c:11:
../../gcc/d/dmd/mtype.c: In member function 'Identifier* 
Type::getTypeInfoIdent()':
../../gcc/d/dmd/mtype.c:2329:33: error: comparison of integer expressions of 
different signedness: 'int' and 'size_t' {aka 'long unsigned int'} 
[-Werror=sign-compare]
 2329 | assert(0 < length && length < namelen); // don't overflow the 
buffer
  |  ~~~^
../../gcc/system.h:742:14: note: in definition of macro 'gcc_assert'
  742 |((void)(!(EXPR) ? fancy_abort (__FILE__, __LINE__, __FUNCTION__), 0 
: 0))
  |  ^~~~
../../gcc/d/dmd/mtype.c:2329:5: note: in expansion of macro 'assert'
 2329 | assert(0 < length && length < namelen); // don't overflow the 
buffer
  | ^~

Andreas.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


[PATCH, d] Committed merge with upstream dmd

2019-01-21 Thread Iain Buclaw
Hi,

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

Main bulk of it reduces the memory footprint of the CTFE interpreter
by replacing new with emplacement new in many places.

Bootstrapped and regression tested on x86_64-linux-gnu.

Committed to trunk as r268124.

-- 
Iain
---
gcc/d/ChangeLog:

2019-01-21  Iain Buclaw  

* d-frontend.cc (Compiler::paintAsType): Update for new signature.
---
diff --git a/gcc/d/d-frontend.cc b/gcc/d/d-frontend.cc
index a1c0d53d1ca..d1d3c78ec86 100644
--- a/gcc/d/d-frontend.cc
+++ b/gcc/d/d-frontend.cc
@@ -446,7 +446,7 @@ Compiler::genCmain (Scope *sc)
so we just lower the value to GCC and return the converted CST.  */
 
 Expression *
-Compiler::paintAsType (Expression *expr, Type *type)
+Compiler::paintAsType (UnionExp *, Expression *expr, Type *type)
 {
   /* We support up to 512-bit values.  */
   unsigned char buffer[64];
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index a3b2db74af4..e8ab8df4f7b 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-cd2034cd7b157dd8f3e94c684061bb1aa630b2b6
+180465274b72a2ff218449f6793af0fbaabbcaa3
 
 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/compiler.h b/gcc/d/dmd/compiler.h
index e8ab9925c5a..a8520788f98 100644
--- a/gcc/d/dmd/compiler.h
+++ b/gcc/d/dmd/compiler.h
@@ -19,6 +19,7 @@ class Expression;
 class Module;
 class Type;
 struct Scope;
+struct UnionExp;
 
 // DMD-generated module `__entrypoint` where the C main resides
 extern Module *entrypoint;
@@ -28,7 +29,7 @@ extern Module *rootHasMain;
 struct Compiler
 {
 // CTFE support for cross-compilation.
-static Expression *paintAsType(Expression *, Type *);
+static Expression *paintAsType(UnionExp *, Expression *, Type *);
 // Backend
 static void loadModule(Module *);
 static void genCmain(Scope *);
diff --git a/gcc/d/dmd/constfold.c b/gcc/d/dmd/constfold.c
index 83f0f3ef14f..ddd356bb966 100644
--- a/gcc/d/dmd/constfold.c
+++ b/gcc/d/dmd/constfold.c
@@ -1457,8 +1457,7 @@ UnionExp Slice(Type *type, Expression *e1, Expression *lwr, Expression *upr)
 memcpy(elements->tdata(),
es1->elements->tdata() + ilwr,
(size_t)(iupr - ilwr) * sizeof((*es1->elements)[0]));
-new() ArrayLiteralExp(e1->loc, elements);
-ue.exp()->type = type;
+new() ArrayLiteralExp(e1->loc, type, elements);
 }
 }
 else
@@ -1606,6 +1605,7 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
 
 new() StringExp(loc, s, len);
 StringExp *es = (StringExp *)ue.exp();
+es->type = type;
 es->sz = sz;
 es->committed = 1;
 }
@@ -1614,9 +1614,8 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
 // Create an ArrayLiteralExp
 Expressions *elements = new Expressions();
 elements->push(e);
-new() ArrayLiteralExp(e->loc, elements);
+new() ArrayLiteralExp(e->loc, type, elements);
 }
-ue.exp()->type = type;
 assert(ue.exp()->type);
 return ue;
 }
@@ -1627,8 +1626,7 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
 // Handle null ~= null
 if (t1->ty == Tarray && t2 == t1->nextOf())
 {
-new() ArrayLiteralExp(e1->loc, e2);
-ue.exp()->type = type;
+new() ArrayLiteralExp(e1->loc, type, e2);
 assert(ue.exp()->type);
 return ue;
 }
@@ -1695,9 +1693,8 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
 {
 (*elems)[i] = ea->getElement(i);
 }
-new() ArrayLiteralExp(e1->loc, elems);
+new() ArrayLiteralExp(e1->loc, type, elems);
 ArrayLiteralExp *dest = (ArrayLiteralExp *)ue.exp();
-dest->type = type;
 sliceAssignArrayLiteralFromString(dest, es, ea->elements->dim);
 assert(ue.exp()->type);
 return ue;
@@ -1715,9 +1712,8 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
 {
 (*elems)[es->len + i] = ea->getElement(i);
 }
-new() ArrayLiteralExp(e1->loc, elems);
+new() ArrayLiteralExp(e1->loc, type, elems);
 ArrayLiteralExp *dest = (ArrayLiteralExp *)ue.exp();
-dest->type = type;
 sliceAssignArrayLiteralFromString(dest, es, 0);
 assert(ue.exp()->type);
 return ue;
@@ -1783,7 +1779,7 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
 // Concatenate the arrays
 Expressions *elems = ArrayLiteralExp::copyElements(e1, e2);
 
-new() ArrayLiteralExp(e1->loc, elems);
+new() ArrayLiteralExp(e1->loc, NULL, elems);
 
 e = ue.exp();
 if (type->toBasetype()->ty == Tsarray)
@@ -1809,7 +1805,7 @@ UnionExp Cat(Type *type, Expression *e1, 

[PATCH, d] Committed merge with upstream dmd

2019-01-14 Thread Iain Buclaw
Hi,

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

One fix in the asm statement parser to stop parsing if the end of the
statement has been reached, and moves all inline asm tests to gdc.dg.
These being adjusted where necessary to test the GCC style instead.

Bootstrapped and tested on x86_64-linux-gnu.

Committed to trunk as r267913.
-- 
Iain
---
gcc/testsuite/ChangeLog:

2019-01-14  Iain Buclaw  

* gdc.dg/asm1.d: New test.
* gdc.dg/asm2.d: New test.
* gdc.dg/asm3.d: New test.
* gdc.dg/asm4.d: New test.
* lib/gdc.exp (gdc_init): Set gcc_error_prefix and gcc_warning_prefix.
---
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index feb65923273..a3b2db74af4 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-6d5b853d30908638d49210ebe600917296b8ab9b
+cd2034cd7b157dd8f3e94c684061bb1aa630b2b6
 
 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/iasmgcc.c b/gcc/d/dmd/iasmgcc.c
index 3c0494d5717..cecbdefe41a 100644
--- a/gcc/d/dmd/iasmgcc.c
+++ b/gcc/d/dmd/iasmgcc.c
@@ -224,7 +224,7 @@ Lerror:
 static GccAsmStatement *parseGccAsm(Parser *p, GccAsmStatement *s)
 {
 s->insn = p->parseExpression();
-if (p->token.value == TOKsemicolon)
+if (p->token.value == TOKsemicolon || p->token.value == TOKeof)
 goto Ldone;
 
 // No semicolon followed after instruction template, treat as extended asm.
@@ -254,7 +254,7 @@ static GccAsmStatement *parseGccAsm(Parser *p, GccAsmStatement *s)
 assert(0);
 }
 
-if (p->token.value == TOKsemicolon)
+if (p->token.value == TOKsemicolon || p->token.value == TOKeof)
 goto Ldone;
 }
 Ldone:
@@ -288,6 +288,7 @@ Statement *gccAsmSemantic(GccAsmStatement *s, Scope *sc)
 *ptoklist = NULL;
 }
 p.token = *toklist;
+p.scanloc = s->loc;
 
 // Parse the gcc asm statement.
 s = parseGccAsm(, s);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d0611e3bc37..373f39d2a8b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2019-01-14  Iain Buclaw  
+
+	* gdc.dg/asm1.d: New test.
+	* gdc.dg/asm2.d: New test.
+	* gdc.dg/asm3.d: New test.
+	* gdc.dg/asm4.d: New test.
+	* lib/gdc.exp (gdc_init): Set gcc_error_prefix and gcc_warning_prefix.
+
 2019-01-13  Jerry DeLisle  
 
 	PR libfortran/88776
diff --git a/gcc/testsuite/gdc.dg/asm1.d b/gcc/testsuite/gdc.dg/asm1.d
new file mode 100644
index 000..7b00e4d54ec
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/asm1.d
@@ -0,0 +1,82 @@
+// { dg-do compile }
+module asm1;
+
+void parse1()
+{
+asm
+{
+""h;// { dg-error "found 'h' when expecting ':'" }
+}
+}
+
+void parse2()
+{
+asm 
+{
+"" : : "g" 1 ? 2 : 3;
+"" : : "g" 1 ? 2 : : 3;
+// { dg-error "expression expected, not ':'" "" { target *-*-* } .-1 }
+// { dg-error "expected constant string constraint for operand" "" { target *-*-* } .-2 }
+}
+}
+
+void parse3()
+{
+asm { "" [; }
+// { dg-error "expression expected, not ';'" "" { target *-*-* } .-1 }
+// { dg-error "found 'EOF' when expecting ','" "" { target *-*-* } .-2 }
+// { dg-error "found 'EOF' when expecting ']'" "" { target *-*-* } .-3 }
+// { dg-error "found 'EOF' when expecting ';'" "" { target *-*-* } .-4 }
+}
+
+void semantic1()
+{
+{
+int one;
+L1:
+;
+}
+asm { "" : : : : L1, L2; }
+// { dg-error "goto skips declaration of variable asm1.semantic1.one" "" { target *-*-* } .-1 }
+// { dg-error "goto skips declaration of variable asm1.semantic1.two" "" { target *-*-* } .-2 }
+{
+int two;
+L2:
+;
+}
+}
+
+void semantic2a(X...)(X expr)
+{
+alias X[0] var1;
+asm { "%0" : "=m" var1; }   // { dg-error "double 'double' is a type, not an lvalue" }
+}
+
+void semantic2()
+{
+   semantic2a(3.6); // { dg-error "template instance asm1.semantic2a!double error instantiating" }
+}
+
+void semantic3()
+{
+asm 
+{
+unknown;// { dg-error "undefined identifier" }
+}
+}
+
+struct S4
+{
+template opDispatch(string Name, P...)
+{
+static void opDispatch(P) {}
+}
+}
+
+void semantic4()
+{
+asm
+{
+"%0" : : "m" S4.foo;// { dg-error "template instance opDispatch!\"foo\" has no value" }
+}
+}
diff --git a/gcc/testsuite/gdc.dg/asm2.d b/gcc/testsuite/gdc.dg/asm2.d
new file mode 100644
index 000..bce0e41a60f
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/asm2.d
@@ -0,0 +1,8 @@
+// { dg-do compile }
+module asm2;
+
+void test()
+{
+asm const shared { }// { dg-error "const/immutable/shared/inout attributes are not allowed on asm blocks" }
+}
+
diff --git a/gcc/testsuite/gdc.dg/asm3.d b/gcc/testsuite/gdc.dg/asm3.d
new file mode 100644
index 000..333d83ec99b
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/asm3.d
@@ -0,0 +1,24 @@

[PATCH, d] Committed merge with upstream dmd

2018-12-17 Thread Iain Buclaw
Hi,

This patch merges the D front-end implementation with dmd upstream 237ca3fbe.

Backports a fix where a bad cast to TypeFunction resulted in memory
corruption.  The logic in the function semantic has been fixed, and
casts have been replaced with a function call to always check the
front-end AST node value.

Bootstrapped and tested on x86_64-linux-gnu.

Committed to trunk as r267207.

-- 
Iain
---
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index a1a1fa0efd1..bc35d4adc1f 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-e2fe2687b817a201528abaa3aa882333e04db01b
+237ca3fbe8f9ac4b64e26ce912c20439ee4fc63a
 
 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/dclass.c b/gcc/d/dmd/dclass.c
index 6fe17b36576..ce9849fc7dd 100644
--- a/gcc/d/dmd/dclass.c
+++ b/gcc/d/dmd/dclass.c
@@ -805,7 +805,7 @@ Lancestorsdone:
 if (fd && !fd->errors)
 {
 //printf("Creating default this(){} for class %s\n", toChars());
-TypeFunction *btf = (TypeFunction *)fd->type;
+TypeFunction *btf = fd->type->toTypeFunction();
 TypeFunction *tf = new TypeFunction(NULL, NULL, 0, LINKd, fd->storage_class);
 tf->mod = btf->mod;
 tf->purity = btf->purity;
@@ -1152,7 +1152,7 @@ int isf(void *param, Dsymbol *s)
 
 bool ClassDeclaration::isFuncHidden(FuncDeclaration *fd)
 {
-//printf("ClassDeclaration::isFuncHidden(class = %s, fd = %s)\n", toChars(), fd->toChars());
+//printf("ClassDeclaration::isFuncHidden(class = %s, fd = %s)\n", toChars(), fd->toPrettyChars());
 Dsymbol *s = search(Loc(), fd->ident, IgnoreAmbiguous | IgnoreErrors);
 if (!s)
 {
@@ -1749,6 +1749,7 @@ bool InterfaceDeclaration::isBaseOf(ClassDeclaration *cd, int *poffset)
 //printf("\tX base %s\n", b->sym->toChars());
 if (this == b->sym)
 {
+//printf("\tfound at offset %d\n", b->offset);
 if (poffset)
 {
 // don't return incorrect offsets https://issues.dlang.org/show_bug.cgi?id=16980
@@ -1882,8 +1883,7 @@ bool BaseClass::fillVtbl(ClassDeclaration *cd, FuncDeclarations *vtbl, int newin
 
 assert(ifd);
 // Find corresponding function in this class
-tf = (ifd->type->ty == Tfunction) ? (TypeFunction *)(ifd->type) : NULL;
-assert(tf);  // should always be non-null
+tf = ifd->type->toTypeFunction();
 fd = cd->findFunc(ifd->ident, tf);
 if (fd && !fd->isAbstract())
 {
diff --git a/gcc/d/dmd/dstruct.c b/gcc/d/dmd/dstruct.c
index f9f15ba9092..77d6174241d 100644
--- a/gcc/d/dmd/dstruct.c
+++ b/gcc/d/dmd/dstruct.c
@@ -46,7 +46,7 @@ FuncDeclaration *search_toString(StructDeclaration *sd)
 if (!tftostring)
 {
 tftostring = new TypeFunction(NULL, Type::tstring, 0, LINKd);
-tftostring = (TypeFunction *)tftostring->merge();
+tftostring = tftostring->merge()->toTypeFunction();
 }
 
 fd = fd->overloadExactMatch(tftostring);
@@ -92,6 +92,7 @@ void semanticTypeInfo(Scope *sc, Type *t)
 }
 void visit(TypeStruct *t)
 {
+//printf("semanticTypeInfo::visit(TypeStruct = %s)\n", t->toChars());
 StructDeclaration *sd = t->sym;
 
 /* Step 1: create TypeInfoDeclaration
diff --git a/gcc/d/dmd/func.c b/gcc/d/dmd/func.c
index c8f9c5c350a..4e1b3e2d2d3 100644
--- a/gcc/d/dmd/func.c
+++ b/gcc/d/dmd/func.c
@@ -411,8 +411,8 @@ static bool canInferAttributes(FuncDeclaration *fd, Scope *sc)
  */
 static void initInferAttributes(FuncDeclaration *fd)
 {
-assert(fd->type->ty == Tfunction);
-TypeFunction *tf = (TypeFunction *)fd->type;
+//printf("initInferAttributes() for %s\n", toPrettyChars());
+TypeFunction *tf = fd->type->toTypeFunction();
 if (tf->purity == PUREimpure) // purity not specified
 fd->flags |= FUNCFLAGpurityInprocess;
 
@@ -495,7 +495,7 @@ void FuncDeclaration::semantic(Scope *sc)
 fld->tok = TOKfunction;
 else
 assert(0);
-linkage = ((TypeFunction *)treq->nextOf())->linkage;
+linkage = treq->nextOf()->toTypeFunction()->linkage;
 }
 else
 linkage = sc->linkage;
@@ -505,11 +505,21 @@ void FuncDeclaration::semantic(Scope *sc)
 
 if (!originalType)
 originalType = type->syntaxCopy();
+if (type->ty != Tfunction)
+{
+if (type->ty != Terror)
+{
+error("%s must be a function instead of %s", toChars(), type->toChars());
+type = Type::terror;
+}
+errors = true;
+return;
+}
 if (!type->deco)
 {
 sc = sc->push();
 sc->stc |= storage_class & (STCdisable | STCdeprecated);  // forward to function type
-TypeFunction *tf = (TypeFunction *)type;
+TypeFunction *tf = type->toTypeFunction();
 
 if (sc->func)
 {
@@ 

[PATCH, d] Committed merge with upstream dmd

2018-12-02 Thread Iain Buclaw
Hi,

This patch merges the D front-end implementation with dmd upstream 5220ad51e.

Backports Ddoc fix that is present in upstream, but did not make its
way into the C++ port of the D front-end implementation.

The old special types for C long, unsigned long, and long double have
also been removed as neither the compiler nor druntime bindings
support handling it anymore.

Commits merged from dmd.

Backport Issue 14633: Fixed false DDoc warnings
https://github.com/dlang/dmd/pull/9027

Remove old support code for struct __c_long/ulong/long_double
https://github.com/dlang/dmd/pull/9028


Bootstrapped and tested on x86_64-linux-gnu.

Committed to trunk as r266719.

-- 
Iain

---
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 7727205bed4..223ffbdc358 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-6243fa6d2ceab4615a9fe21c5bc9484e52bb2d1e
+5220ad51eebe06754e6881d9bd5aab89dba2b065
 
 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/cppmangle.c b/gcc/d/dmd/cppmangle.c
index d2d357667cb..ad88242d820 100644
--- a/gcc/d/dmd/cppmangle.c
+++ b/gcc/d/dmd/cppmangle.c
@@ -952,15 +952,6 @@ public:
 if (t->isImmutable() || t->isShared())
 return error(t);
 
-/* __c_long and __c_ulong get special mangling
- */
-Identifier *id = t->sym->ident;
-//printf("struct id = '%s'\n", id->toChars());
-if (id == Id::__c_long)
-return writeBasicType(t, 0, 'l');
-else if (id == Id::__c_ulong)
-return writeBasicType(t, 0, 'm');
-
 //printf("TypeStruct %s\n", t->toChars());
 doSymbol(t);
 }
diff --git a/gcc/d/dmd/doc.c b/gcc/d/dmd/doc.c
index d35ca7b2522..797991ee2c4 100644
--- a/gcc/d/dmd/doc.c
+++ b/gcc/d/dmd/doc.c
@@ -133,6 +133,25 @@ bool isCVariadicParameter(Dsymbols *a, const utf8_t *p, size_t len)
 return false;
 }
 
+/
+ */
+static Parameter *isFunctionParameter(Dsymbol *s, const utf8_t *p, size_t len)
+{
+TypeFunction *tf = isTypeFunction(s);
+if (tf && tf->parameters)
+{
+for (size_t k = 0; k < tf->parameters->dim; k++)
+{
+Parameter *fparam = (*tf->parameters)[k];
+if (fparam->ident && cmp(fparam->ident->toChars(), p, len) == 0)
+{
+return fparam;
+}
+}
+}
+return NULL;
+}
+
 static Dsymbol *getEponymousMember(TemplateDeclaration *td)
 {
 if (!td->onemember)
@@ -150,6 +169,54 @@ static Dsymbol *getEponymousMember(TemplateDeclaration *td)
 return NULL;
 }
 
+/
+ */
+static Parameter *isEponymousFunctionParameter(Dsymbols *a, const utf8_t *p, size_t len)
+{
+for (size_t i = 0; i < a->dim; i++)
+{
+TemplateDeclaration *td = (*a)[i]->isTemplateDeclaration();
+if (td && td->onemember)
+{
+/* Case 1: we refer to a template declaration inside the template
+
+   /// ...ddoc...
+   template case1(T) {
+ void case1(R)() {}
+   }
+ */
+td = td->onemember->isTemplateDeclaration();
+}
+if (!td)
+{
+/* Case 2: we're an alias to a template declaration
+
+   /// ...ddoc...
+   alias case2 = case1!int;
+ */
+AliasDeclaration *ad = (*a)[i]->isAliasDeclaration();
+if (ad && ad->aliassym)
+{
+td = ad->aliassym->isTemplateDeclaration();
+}
+}
+while (td)
+{
+Dsymbol *sym = getEponymousMember(td);
+if (sym)
+{
+Parameter *fparam = isFunctionParameter(sym, p, len);
+if (fparam)
+{
+return fparam;
+}
+}
+td = td->overnext;
+}
+}
+return NULL;
+}
+
 static TemplateDeclaration *getEponymousParent(Dsymbol *s)
 {
 if (!s->parent)
@@ -1590,6 +1657,12 @@ void ParamSection::write(Loc loc, DocComment *, Scope *sc, Dsymbols *a, OutBuffe
 {
 size_t o = buf->offset;
 Parameter *fparam = isFunctionParameter(a, namestart, namelen);
+if (!fparam)
+{
+// Comments on a template might refer to function parameters within.
+// Search the parameters of nested eponymous functions (with the same name.)
+fparam = isEponymousFunctionParameter(a, namestart, namelen);
+}
 bool isCVariadic = isCVariadicParameter(a, namestart, namelen);
 if (isCVariadic)
 {
@@ -2085,17 +2158,10 @@ Parameter *isFunctionParameter(Dsymbols *a, const 

[PATCH, d] Committed merge with upstream dmd

2018-11-04 Thread Iain Buclaw
Hi,

I've merged into the D front-end patches sent to upstream dmd, most
address problems found when building the compiler on OSX and Solaris.

This introduces a new header that pulls in system includes for use
only in the DMD front-end part of the compiler, fixing up uses of
problematic functions that are prevalent throughout the code.

Commits merged from dmd.

Fix build of the D frontend on the Hurd and KFreeBSD.
Initial patch from Matthias Klose.
https://github.com/dlang/dmd/pull/8893

Don't care about D/C++ compatibility in C++ port.
Fixes build error in https://gcc.gnu.org/PR87788
https://github.com/dlang/dmd/pull/8895

Allow compiling front-end headers with strict warnings.
https://github.com/dlang/dmd/pull/8909

Add root/system.h header for wrapping system includes.
Fixes https://gcc.gnu.org/PR87865
https://github.com/dlang/dmd/pull/8910

Move checkedint to dmd/root.
https://github.com/dlang/dmd/pull/8912

Use rmem instead of libc for malloc() and strdup().
https://github.com/dlang/dmd/pull/8913

Use align(8) for alignment of UnionExp, fixing several BUS errors
due to alignment issues on SPARC.
https://github.com/dlang/dmd/pull/8914

Don't pass NULL pointer as format parameter to errorSupplemental.
https://github.com/dlang/dmd/pull/8916

-- 
Iain

---
gcc/d/ChangeLog:

2018-11-05  Iain Buclaw  

PR d/87865
* d-system.h: New file.
---
diff --git a/gcc/d/d-system.h b/gcc/d/d-system.h
new file mode 100644
index 000..25a83b675b5
--- /dev/null
+++ b/gcc/d/d-system.h
@@ -0,0 +1,53 @@
+/* d-system.h -- DMD frontend inclusion of gcc header files.
+ * Copyright (C) 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
+ * .
+ */
+
+#ifndef GCC_D_SYSTEM_H
+#define GCC_D_SYSTEM_H
+
+#include "config.h"
+#include "system.h"
+
+/* Used by the dmd front-end to determine if we have POSIX-style IO.  */
+#define POSIX (__linux__ || __GLIBC__ || __gnu_hurd__ || __APPLE__ \
+	   || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun)
+
+/* Forward assert invariants to gcc_assert.  */
+#undef assert
+#define assert(EXPR) gcc_assert(EXPR)
+
+/* Forward ctype.h macros used by the dmd front-end to safe-ctype.h.  */
+#undef isalpha
+#define isalpha(c) ISALPHA(c)
+#undef isalnum
+#define isalnum(c) ISALNUM(c)
+#undef isdigit
+#define isdigit(c) ISDIGIT(c)
+#undef islower
+#define islower(c) ISLOWER(c)
+#undef isprint
+#define isprint(c) ISPRINT(c)
+#undef isspace
+#define isspace(c) ISSPACE(c)
+#undef isupper
+#define isupper(c) ISUPPER(c)
+#undef isxdigit
+#define isxdigit(c) ISXDIGIT(c)
+#undef tolower
+#define tolower(c) TOLOWER(c)
+
+#endif  /* GCC_D_SYSTEM_H  */
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
new file mode 100644
index 000..7727205bed4
--- /dev/null
+++ b/gcc/d/dmd/MERGE
@@ -0,0 +1,4 @@
+6243fa6d2ceab4615a9fe21c5bc9484e52bb2d1e
+
+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/access.c b/gcc/d/dmd/access.c
index 37e9c8681d3..cd60cedc2a5 100644
--- a/gcc/d/dmd/access.c
+++ b/gcc/d/dmd/access.c
@@ -7,10 +7,7 @@
  * https://github.com/D-Programming-Language/dmd/blob/master/src/access.c
  */
 
-#include 
-#include 
-#include 
-
+#include "root/dsystem.h"
 #include "root/root.h"
 #include "root/rmem.h"
 
diff --git a/gcc/d/dmd/aggregate.h b/gcc/d/dmd/aggregate.h
index d7db82b0f0e..cac0b8efd9f 100644
--- a/gcc/d/dmd/aggregate.h
+++ b/gcc/d/dmd/aggregate.h
@@ -191,7 +191,7 @@ public:
 void semantic(Scope *sc);
 void semanticTypeInfoMembers();
 Dsymbol *search(const Loc , Identifier *ident, int flags = SearchLocalsOnly);
-const char *kind();
+const char *kind() const;
 void finalizeSize();
 bool fit(Loc loc, Scope *sc, Expressions *elements, Type *stype);
 bool isPOD();
@@ -205,7 +205,7 @@ class UnionDeclaration : public StructDeclaration
 public:
 UnionDeclaration(Loc loc, Identifier *id);
 Dsymbol *syntaxCopy(Dsymbol *s);
-const char *kind();
+const char *kind() const;
 
 UnionDeclaration *isUnionDeclaration() { return this; }
 void accept(Visitor *v) { v->visit(this); }
@@ -306,7 +306,7 @@ public:
 virtual bool isCPPinterface() const;
 bool isAbstract();
 virtual int vtblOffset() const;
-const char *kind();