aboutsummaryrefslogtreecommitdiff
path: root/gcc/d
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2018-11-04 23:34:44 +0000
committerIain Buclaw <ibuclaw@gcc.gnu.org>2018-11-04 23:34:44 +0000
commitf9ab59ffe7f22c533df54f28cd7e71affbce854b (patch)
tree450d012939fe9a9d4435c2cf7002a626c0431429 /gcc/d
parente8bf3d5ed983791a658b86f4eae338e13b6fdc3f (diff)
downloadgcc-f9ab59ffe7f22c533df54f28cd7e71affbce854b.zip
gcc-f9ab59ffe7f22c533df54f28cd7e71affbce854b.tar.gz
gcc-f9ab59ffe7f22c533df54f28cd7e71affbce854b.tar.bz2
Merge dmd upstream 6243fa6d2
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 gcc/d/ChangeLog: 2018-11-05 Iain Buclaw <ibuclaw@gdcproject.org> PR d/87865 * d-system.h: New file. From-SVN: r265780
Diffstat (limited to 'gcc/d')
-rw-r--r--gcc/d/ChangeLog5
-rw-r--r--gcc/d/d-system.h53
-rw-r--r--gcc/d/dmd/MERGE4
-rw-r--r--gcc/d/dmd/access.c5
-rw-r--r--gcc/d/dmd/aggregate.h8
-rw-r--r--gcc/d/dmd/aliasthis.c5
-rw-r--r--gcc/d/dmd/aliasthis.h2
-rw-r--r--gcc/d/dmd/apply.c3
-rw-r--r--gcc/d/dmd/argtypes.c6
-rw-r--r--gcc/d/dmd/arrayop.c5
-rw-r--r--gcc/d/dmd/attrib.c6
-rw-r--r--gcc/d/dmd/attrib.h4
-rw-r--r--gcc/d/dmd/canthrow.c3
-rw-r--r--gcc/d/dmd/clone.c6
-rw-r--r--gcc/d/dmd/compiler.h7
-rw-r--r--gcc/d/dmd/cond.c4
-rw-r--r--gcc/d/dmd/constfold.c17
-rw-r--r--gcc/d/dmd/cppmangle.c6
-rw-r--r--gcc/d/dmd/ctfeexpr.c7
-rw-r--r--gcc/d/dmd/dcast.c5
-rw-r--r--gcc/d/dmd/dclass.c10
-rw-r--r--gcc/d/dmd/declaration.c16
-rw-r--r--gcc/d/dmd/declaration.h24
-rw-r--r--gcc/d/dmd/delegatize.c3
-rw-r--r--gcc/d/dmd/denum.c9
-rw-r--r--gcc/d/dmd/dimport.c7
-rw-r--r--gcc/d/dmd/dinterpret.c7
-rw-r--r--gcc/d/dmd/dmacro.c6
-rw-r--r--gcc/d/dmd/dmangle.c6
-rw-r--r--gcc/d/dmd/dmodule.c23
-rw-r--r--gcc/d/dmd/doc.c7
-rw-r--r--gcc/d/dmd/doc.h5
-rw-r--r--gcc/d/dmd/dscope.c5
-rw-r--r--gcc/d/dmd/dstruct.c9
-rw-r--r--gcc/d/dmd/dsymbol.c16
-rw-r--r--gcc/d/dmd/dsymbol.h8
-rw-r--r--gcc/d/dmd/dtemplate.c10
-rw-r--r--gcc/d/dmd/dversion.c8
-rw-r--r--gcc/d/dmd/entity.c4
-rw-r--r--gcc/d/dmd/enum.h4
-rw-r--r--gcc/d/dmd/errors.h1
-rw-r--r--gcc/d/dmd/expression.c7
-rw-r--r--gcc/d/dmd/expression.h14
-rw-r--r--gcc/d/dmd/expressionsem.c7
-rw-r--r--gcc/d/dmd/func.c17
-rw-r--r--gcc/d/dmd/globals.h15
-rw-r--r--gcc/d/dmd/hdrgen.c9
-rw-r--r--gcc/d/dmd/hdrgen.h3
-rw-r--r--gcc/d/dmd/identifier.c6
-rw-r--r--gcc/d/dmd/idgen.c5
-rw-r--r--gcc/d/dmd/impcnvgen.c3
-rw-r--r--gcc/d/dmd/imphint.c6
-rw-r--r--gcc/d/dmd/import.h2
-rw-r--r--gcc/d/dmd/init.c5
-rw-r--r--gcc/d/dmd/initsem.c2
-rw-r--r--gcc/d/dmd/intrange.c3
-rw-r--r--gcc/d/dmd/json.c5
-rw-r--r--gcc/d/dmd/lexer.c11
-rw-r--r--gcc/d/dmd/macro.h6
-rw-r--r--gcc/d/dmd/mars.h4
-rw-r--r--gcc/d/dmd/module.h4
-rw-r--r--gcc/d/dmd/mtype.c52
-rw-r--r--gcc/d/dmd/nspace.c6
-rw-r--r--gcc/d/dmd/nspace.h2
-rw-r--r--gcc/d/dmd/opover.c7
-rw-r--r--gcc/d/dmd/optimize.c7
-rw-r--r--gcc/d/dmd/parse.c6
-rw-r--r--gcc/d/dmd/parse.h4
-rw-r--r--gcc/d/dmd/root/aav.c6
-rw-r--r--gcc/d/dmd/root/aav.h2
-rw-r--r--gcc/d/dmd/root/array.h6
-rw-r--r--gcc/d/dmd/root/checkedint.c (renamed from gcc/d/dmd/checkedint.c)6
-rw-r--r--gcc/d/dmd/root/checkedint.h (renamed from gcc/d/dmd/checkedint.h)9
-rw-r--r--gcc/d/dmd/root/dcompat.h2
-rw-r--r--gcc/d/dmd/root/dsystem.h24
-rw-r--r--gcc/d/dmd/root/file.c25
-rw-r--r--gcc/d/dmd/root/file.h3
-rw-r--r--gcc/d/dmd/root/filename.c20
-rw-r--r--gcc/d/dmd/root/hash.h3
-rw-r--r--gcc/d/dmd/root/object.h6
-rw-r--r--gcc/d/dmd/root/outbuffer.c11
-rw-r--r--gcc/d/dmd/root/outbuffer.h5
-rw-r--r--gcc/d/dmd/root/port.h4
-rw-r--r--gcc/d/dmd/root/rmem.c37
-rw-r--r--gcc/d/dmd/root/rmem.h2
-rw-r--r--gcc/d/dmd/root/rootobject.c3
-rw-r--r--gcc/d/dmd/root/speller.c11
-rw-r--r--gcc/d/dmd/root/stringtable.c6
-rw-r--r--gcc/d/dmd/sapply.c3
-rw-r--r--gcc/d/dmd/sideeffect.c3
-rw-r--r--gcc/d/dmd/statement.c4
-rw-r--r--gcc/d/dmd/statementsem.c7
-rw-r--r--gcc/d/dmd/staticassert.c6
-rw-r--r--gcc/d/dmd/staticassert.h2
-rw-r--r--gcc/d/dmd/target.h1
-rw-r--r--gcc/d/dmd/template.h6
-rw-r--r--gcc/d/dmd/tokens.c3
-rw-r--r--gcc/d/dmd/traits.c9
-rw-r--r--gcc/d/dmd/unittests.c26
-rw-r--r--gcc/d/dmd/utf.c2
-rw-r--r--gcc/d/dmd/utf.h2
-rw-r--r--gcc/d/dmd/utils.c5
-rw-r--r--gcc/d/dmd/version.h4
-rw-r--r--gcc/d/dmd/visitor.h2
104 files changed, 360 insertions, 483 deletions
diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog
index 117dbc0..d534f36 100644
--- a/gcc/d/ChangeLog
+++ b/gcc/d/ChangeLog
@@ -1,3 +1,8 @@
+2018-11-05 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ PR d/87865
+ * d-system.h: New file.
+
2018-11-01 Jakub Jelinek <jakub@redhat.com>
PR d/87824
diff --git a/gcc/d/d-system.h b/gcc/d/d-system.h
new file mode 100644
index 0000000..25a83b6
--- /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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#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 0000000..7727205
--- /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 37e9c86..cd60ced 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 <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
+#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 d7db82b..cac0b8e 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 &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();
+ const char *kind() const;
void addLocalClass(ClassDeclarations *);
@@ -326,7 +326,7 @@ public:
void semantic(Scope *sc);
bool isBaseOf(ClassDeclaration *cd, int *poffset);
bool isBaseOf(BaseClass *bc, int *poffset);
- const char *kind();
+ const char *kind() const;
int vtblOffset() const;
bool isCPPinterface() const;
bool isCOMinterface() const;
diff --git a/gcc/d/dmd/aliasthis.c b/gcc/d/dmd/aliasthis.c
index 50921ec..f4d627f 100644
--- a/gcc/d/dmd/aliasthis.c
+++ b/gcc/d/dmd/aliasthis.c
@@ -8,8 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/aliasthis.c
*/
-#include <stdio.h>
-#include <assert.h>
+#include "root/dsystem.h"
#include "mars.h"
#include "identifier.h"
@@ -163,7 +162,7 @@ void AliasThis::semantic(Scope *sc)
semanticRun = PASSsemanticdone;
}
-const char *AliasThis::kind()
+const char *AliasThis::kind() const
{
return "alias this";
}
diff --git a/gcc/d/dmd/aliasthis.h b/gcc/d/dmd/aliasthis.h
index e5b0280..290ccd6 100644
--- a/gcc/d/dmd/aliasthis.h
+++ b/gcc/d/dmd/aliasthis.h
@@ -24,7 +24,7 @@ public:
Dsymbol *syntaxCopy(Dsymbol *);
void semantic(Scope *sc);
- const char *kind();
+ const char *kind() const;
AliasThis *isAliasThis() { return this; }
void accept(Visitor *v) { v->visit(this); }
};
diff --git a/gcc/d/dmd/apply.c b/gcc/d/dmd/apply.c
index f20e411..bec32a8 100644
--- a/gcc/d/dmd/apply.c
+++ b/gcc/d/dmd/apply.c
@@ -8,8 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/apply.c
*/
-#include <stdio.h>
-#include <assert.h>
+#include "root/dsystem.h"
#include "mars.h"
#include "expression.h"
diff --git a/gcc/d/dmd/argtypes.c b/gcc/d/dmd/argtypes.c
index cad8d4e..c37d48a 100644
--- a/gcc/d/dmd/argtypes.c
+++ b/gcc/d/dmd/argtypes.c
@@ -8,10 +8,8 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/argtypes.c
*/
-#include <stdio.h>
-#include <assert.h>
-
-#include "checkedint.h"
+#include "root/dsystem.h"
+#include "root/checkedint.h"
#include "mars.h"
#include "dsymbol.h"
diff --git a/gcc/d/dmd/arrayop.c b/gcc/d/dmd/arrayop.c
index 0ea0d32..91c1b76 100644
--- a/gcc/d/dmd/arrayop.c
+++ b/gcc/d/dmd/arrayop.c
@@ -8,10 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/arrayop.c
*/
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
+#include "root/dsystem.h"
#include "root/rmem.h"
#include "root/aav.h"
diff --git a/gcc/d/dmd/attrib.c b/gcc/d/dmd/attrib.c
index c4270ea..0572851 100644
--- a/gcc/d/dmd/attrib.c
+++ b/gcc/d/dmd/attrib.c
@@ -8,11 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/attrib.c
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <string.h> // memcpy()
-
+#include "root/dsystem.h" // memcmp()
#include "root/rmem.h"
#include "mars.h"
diff --git a/gcc/d/dmd/attrib.h b/gcc/d/dmd/attrib.h
index 83486a9..a491605 100644
--- a/gcc/d/dmd/attrib.h
+++ b/gcc/d/dmd/attrib.h
@@ -212,10 +212,10 @@ public:
Dsymbols *cache;
Dsymbol *syntaxCopy(Dsymbol *s);
- bool oneMember(Dsymbol *ps, Identifier *ident);
+ bool oneMember(Dsymbol **ps, Identifier *ident);
Dsymbols *include(Scope *sc, ScopeDsymbol *sds);
void addMember(Scope *sc, ScopeDsymbol *sds);
- void addComment(const char *comment);
+ void addComment(const utf8_t *comment);
void setScope(Scope *sc);
void importAll(Scope *sc);
void semantic(Scope *sc);
diff --git a/gcc/d/dmd/canthrow.c b/gcc/d/dmd/canthrow.c
index a00741b..ec15153 100644
--- a/gcc/d/dmd/canthrow.c
+++ b/gcc/d/dmd/canthrow.c
@@ -8,8 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/canthrow.c
*/
-#include <stdio.h>
-#include <assert.h>
+#include "root/dsystem.h"
#include "mars.h"
#include "init.h"
diff --git a/gcc/d/dmd/clone.c b/gcc/d/dmd/clone.c
index 9105d11..4384dc8 100644
--- a/gcc/d/dmd/clone.c
+++ b/gcc/d/dmd/clone.c
@@ -8,11 +8,9 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/clone.c
*/
-#include <stdio.h>
-#include <assert.h>
-#include <new>
-
+#include "root/dsystem.h"
#include "root/root.h"
+
#include "aggregate.h"
#include "scope.h"
#include "mtype.h"
diff --git a/gcc/d/dmd/compiler.h b/gcc/d/dmd/compiler.h
index cfcc317..6c5cf7b 100644
--- a/gcc/d/dmd/compiler.h
+++ b/gcc/d/dmd/compiler.h
@@ -10,6 +10,8 @@
#pragma once
+#include "root/array.h"
+
// This file contains a data structure that describes a back-end compiler
// and implements compiler-specific actions.
@@ -18,6 +20,11 @@ class Module;
class Type;
struct Scope;
+// DMD-generated module `__entrypoint` where the C main resides
+extern Module *entrypoint;
+// Module in which the D main is
+extern Module *rootHasMain;
+
struct Compiler
{
// CTFE support for cross-compilation.
diff --git a/gcc/d/dmd/cond.c b/gcc/d/dmd/cond.c
index 047eca2..0538929 100644
--- a/gcc/d/dmd/cond.c
+++ b/gcc/d/dmd/cond.c
@@ -8,9 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/cond.c
*/
-#include <stdio.h>
-#include <assert.h>
-#include <string.h> // strcmp()
+#include "root/dsystem.h" // strcmp()
#include "mars.h"
#include "id.h"
diff --git a/gcc/d/dmd/constfold.c b/gcc/d/dmd/constfold.c
index 43e831f..4b5dceb 100644
--- a/gcc/d/dmd/constfold.c
+++ b/gcc/d/dmd/constfold.c
@@ -8,12 +8,11 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/constfold.c
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <string.h> // mem{cpy|set|cmp}()
+#include "root/dsystem.h" // mem{cpy|set|cmp}()
+
+#ifndef IN_GCC
#include <math.h>
-#include <new>
+#endif
#include "root/rmem.h"
#include "root/root.h"
@@ -481,13 +480,21 @@ UnionExp Mod(Loc loc, Type *type, Expression *e1, Expression *e2)
{
real_t r2 = e2->toReal();
+#ifdef IN_GCC
c = complex_t(e1->toReal() % r2, e1->toImaginary() % r2);
+#else
+ c = complex_t(::fmodl(e1->toReal(), r2), ::fmodl(e1->toImaginary(), r2));
+#endif
}
else if (e2->type->isimaginary())
{
real_t i2 = e2->toImaginary();
+#ifdef IN_GCC
c = complex_t(e1->toReal() % i2, e1->toImaginary() % i2);
+#else
+ c = complex_t(::fmodl(e1->toReal(), i2), ::fmodl(e1->toImaginary(), i2));
+#endif
}
else
assert(0);
diff --git a/gcc/d/dmd/cppmangle.c b/gcc/d/dmd/cppmangle.c
index bb919a5..d2d3576 100644
--- a/gcc/d/dmd/cppmangle.c
+++ b/gcc/d/dmd/cppmangle.c
@@ -21,9 +21,7 @@
* enter `C++, mangling` as the keywords.
*/
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
+#include "root/dsystem.h"
#include "mars.h"
#include "dsymbol.h"
@@ -47,9 +45,9 @@ class CppMangleVisitor : public Visitor
{
Objects components; // array of components available for substitution
OutBuffer *buf; // append the mangling to buf[]
+ public:
Loc loc; // location for use in error messages
- public:
// Write <seq-id> to buf
void write_seq_id(size_t i)
{
diff --git a/gcc/d/dmd/ctfeexpr.c b/gcc/d/dmd/ctfeexpr.c
index ad5b827..430342d 100644
--- a/gcc/d/dmd/ctfeexpr.c
+++ b/gcc/d/dmd/ctfeexpr.c
@@ -8,12 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/ctfeexpr.c
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <string.h> // mem{cpy|set}()
-#include <new>
-
+#include "root/dsystem.h" // mem{cpy|set}()
#include "root/rmem.h"
#include "mars.h"
diff --git a/gcc/d/dmd/dcast.c b/gcc/d/dmd/dcast.c
index ee3bfd9..3947166 100644
--- a/gcc/d/dmd/dcast.c
+++ b/gcc/d/dmd/dcast.c
@@ -8,10 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/cast.c
*/
-#include <stdio.h>
-#include <assert.h>
-#include <string.h> // mem{set|cpy}()
-
+#include "root/dsystem.h" // mem{set|cpy}()
#include "root/rmem.h"
#include "mars.h"
diff --git a/gcc/d/dmd/dclass.c b/gcc/d/dmd/dclass.c
index 414332c..6fe17b3 100644
--- a/gcc/d/dmd/dclass.c
+++ b/gcc/d/dmd/dclass.c
@@ -8,11 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/class.c
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <string.h> // mem{cpy|set}()
-
+#include "root/dsystem.h" // mem{cpy|set}()
#include "root/root.h"
#include "root/rmem.h"
@@ -1389,7 +1385,7 @@ int ClassDeclaration::vtblOffset() const
/****************************************
*/
-const char *ClassDeclaration::kind()
+const char *ClassDeclaration::kind() const
{
return "class";
}
@@ -1827,7 +1823,7 @@ bool InterfaceDeclaration::isCPPinterface() const
/*******************************************
*/
-const char *InterfaceDeclaration::kind()
+const char *InterfaceDeclaration::kind() const
{
return "interface";
}
diff --git a/gcc/d/dmd/declaration.c b/gcc/d/dmd/declaration.c
index 76132b9..9f43b88 100644
--- a/gcc/d/dmd/declaration.c
+++ b/gcc/d/dmd/declaration.c
@@ -8,10 +8,8 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/declaration.c
*/
-#include <stdio.h>
-#include <assert.h>
-
-#include "checkedint.h"
+#include "root/dsystem.h"
+#include "root/checkedint.h"
#include "errors.h"
#include "init.h"
@@ -87,7 +85,7 @@ void Declaration::semantic(Scope *)
{
}
-const char *Declaration::kind()
+const char *Declaration::kind() const
{
return "declaration";
}
@@ -188,7 +186,7 @@ Dsymbol *TupleDeclaration::syntaxCopy(Dsymbol *)
return NULL;
}
-const char *TupleDeclaration::kind()
+const char *TupleDeclaration::kind() const
{
return "tuple";
}
@@ -575,7 +573,7 @@ bool AliasDeclaration::overloadInsert(Dsymbol *s)
return true;
}
-const char *AliasDeclaration::kind()
+const char *AliasDeclaration::kind() const
{
return "alias";
}
@@ -705,7 +703,7 @@ OverDeclaration::OverDeclaration(Identifier *ident, Dsymbol *s, bool hasOverload
}
}
-const char *OverDeclaration::kind()
+const char *OverDeclaration::kind() const
{
return "overload alias"; // todo
}
@@ -1770,7 +1768,7 @@ void VarDeclaration::setFieldOffset(AggregateDeclaration *ad, unsigned *poffset,
//printf(" addField '%s' to '%s' at offset %d, size = %d\n", toChars(), ad->toChars(), offset, memsize);
}
-const char *VarDeclaration::kind()
+const char *VarDeclaration::kind() const
{
return "variable";
}
diff --git a/gcc/d/dmd/declaration.h b/gcc/d/dmd/declaration.h
index 071ce2c..6952bffb 100644
--- a/gcc/d/dmd/declaration.h
+++ b/gcc/d/dmd/declaration.h
@@ -127,7 +127,7 @@ public:
Declaration(Identifier *id);
void semantic(Scope *sc);
- const char *kind();
+ const char *kind() const;
d_uns64 size(Loc loc);
int checkModify(Loc loc, Scope *sc, Type *t, Expression *e1, int flag);
@@ -177,7 +177,7 @@ public:
TupleDeclaration(Loc loc, Identifier *ident, Objects *objects);
Dsymbol *syntaxCopy(Dsymbol *);
- const char *kind();
+ const char *kind() const;
Type *getType();
Dsymbol *toAlias2();
bool needThis();
@@ -202,7 +202,7 @@ public:
void semantic(Scope *sc);
void aliasSemantic(Scope *sc);
bool overloadInsert(Dsymbol *s);
- const char *kind();
+ const char *kind() const;
Type *getType();
Dsymbol *toAlias();
Dsymbol *toAlias2();
@@ -222,7 +222,7 @@ public:
bool hasOverloads;
OverDeclaration(Identifier *ident, Dsymbol *s, bool hasOverloads = true);
- const char *kind();
+ const char *kind() const;
void semantic(Scope *sc);
bool equals(RootObject *o);
bool overloadInsert(Dsymbol *s);
@@ -269,7 +269,7 @@ public:
void semantic(Scope *sc);
void setFieldOffset(AggregateDeclaration *ad, unsigned *poffset, bool isunion);
void semantic2(Scope *sc);
- const char *kind();
+ const char *kind() const;
AggregateDeclaration *isThis();
bool needThis();
bool isExport() const;
@@ -654,7 +654,7 @@ public:
virtual bool isFinalFunc();
virtual bool addPreInvariant();
virtual bool addPostInvariant();
- const char *kind();
+ const char *kind() const;
FuncDeclaration *isUnique();
bool checkNestedReference(Scope *sc, Loc loc);
bool needsClosure();
@@ -690,7 +690,7 @@ public:
FuncAliasDeclaration(Identifier *ident, FuncDeclaration *funcalias, bool hasOverloads = true);
FuncAliasDeclaration *isFuncAliasDeclaration() { return this; }
- const char *kind();
+ const char *kind() const;
FuncDeclaration *toAliasFunc();
void accept(Visitor *v) { v->visit(this); }
@@ -717,7 +717,7 @@ public:
void modifyReturns(Scope *sc, Type *tret);
FuncLiteralDeclaration *isFuncLiteralDeclaration() { return this; }
- const char *kind();
+ const char *kind() const;
const char *toPrettyChars(bool QualifyTypes = false);
void accept(Visitor *v) { v->visit(this); }
};
@@ -728,7 +728,7 @@ public:
CtorDeclaration(Loc loc, Loc endloc, StorageClass stc, Type *type);
Dsymbol *syntaxCopy(Dsymbol *);
void semantic(Scope *sc);
- const char *kind();
+ const char *kind() const;
const char *toChars();
bool isVirtual();
bool addPreInvariant();
@@ -760,7 +760,7 @@ public:
DtorDeclaration(Loc loc, Loc endloc, StorageClass stc, Identifier *id);
Dsymbol *syntaxCopy(Dsymbol *);
void semantic(Scope *sc);
- const char *kind();
+ const char *kind() const;
const char *toChars();
bool isVirtual();
bool addPreInvariant();
@@ -870,7 +870,7 @@ public:
NewDeclaration(Loc loc, Loc endloc, StorageClass stc, Parameters *arguments, int varargs);
Dsymbol *syntaxCopy(Dsymbol *);
void semantic(Scope *sc);
- const char *kind();
+ const char *kind() const;
bool isVirtual();
bool addPreInvariant();
bool addPostInvariant();
@@ -888,7 +888,7 @@ public:
DeleteDeclaration(Loc loc, Loc endloc, StorageClass stc, Parameters *arguments);
Dsymbol *syntaxCopy(Dsymbol *);
void semantic(Scope *sc);
- const char *kind();
+ const char *kind() const;
bool isDelete();
bool isVirtual();
bool addPreInvariant();
diff --git a/gcc/d/dmd/delegatize.c b/gcc/d/dmd/delegatize.c
index 99fe938..8745026 100644
--- a/gcc/d/dmd/delegatize.c
+++ b/gcc/d/dmd/delegatize.c
@@ -8,8 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/delegatize.c
*/
-#include <stdio.h>
-#include <assert.h>
+#include "root/dsystem.h"
#include "mars.h"
#include "expression.h"
diff --git a/gcc/d/dmd/denum.c b/gcc/d/dmd/denum.c
index 4107f11..56652f2 100644
--- a/gcc/d/dmd/denum.c
+++ b/gcc/d/dmd/denum.c
@@ -8,10 +8,9 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/enum.c
*/
-#include <stdio.h>
-#include <assert.h>
-
+#include "root/dsystem.h"
#include "root/root.h"
+
#include "errors.h"
#include "enum.h"
#include "mtype.h"
@@ -457,7 +456,7 @@ Type *EnumDeclaration::getType()
return type;
}
-const char *EnumDeclaration::kind()
+const char *EnumDeclaration::kind() const
{
return "enum";
}
@@ -515,7 +514,7 @@ Dsymbol *EnumMember::syntaxCopy(Dsymbol *s)
origType ? origType->syntaxCopy() : NULL);
}
-const char *EnumMember::kind()
+const char *EnumMember::kind() const
{
return "enum member";
}
diff --git a/gcc/d/dmd/dimport.c b/gcc/d/dmd/dimport.c
index 03b3d1f..922e18a 100644
--- a/gcc/d/dmd/dimport.c
+++ b/gcc/d/dmd/dimport.c
@@ -8,10 +8,9 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/import.c
*/
-#include <stdio.h>
-#include <assert.h>
-
+#include "root/dsystem.h"
#include "root/root.h"
+
#include "mars.h"
#include "dsymbol.h"
#include "import.h"
@@ -70,7 +69,7 @@ void Import::addAlias(Identifier *name, Identifier *alias)
aliases.push(alias);
}
-const char *Import::kind()
+const char *Import::kind() const
{
return isstatic ? "static import" : "import";
}
diff --git a/gcc/d/dmd/dinterpret.c b/gcc/d/dmd/dinterpret.c
index 54bf00d..2bb1aac 100644
--- a/gcc/d/dmd/dinterpret.c
+++ b/gcc/d/dmd/dinterpret.c
@@ -8,12 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/interpret.c
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <string.h> // mem{cpy|set}()
-#include <new>
-
+#include "root/dsystem.h" // mem{cpy|set}()
#include "root/rmem.h"
#include "mars.h"
diff --git a/gcc/d/dmd/dmacro.c b/gcc/d/dmd/dmacro.c
index a5d8da1..c617122 100644
--- a/gcc/d/dmd/dmacro.c
+++ b/gcc/d/dmd/dmacro.c
@@ -11,11 +11,7 @@
/* Simple macro text processor.
*/
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <ctype.h>
-#include <assert.h>
+#include "root/dsystem.h"
#include "mars.h"
#include "errors.h"
diff --git a/gcc/d/dmd/dmangle.c b/gcc/d/dmd/dmangle.c
index 9734624..7686c69 100644
--- a/gcc/d/dmd/dmangle.c
+++ b/gcc/d/dmd/dmangle.c
@@ -8,11 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/mangle.c
*/
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <assert.h>
-
+#include "root/dsystem.h"
#include "root/root.h"
#include "mangle.h"
diff --git a/gcc/d/dmd/dmodule.c b/gcc/d/dmd/dmodule.c
index a374aac..55b54b1 100644
--- a/gcc/d/dmd/dmodule.c
+++ b/gcc/d/dmd/dmodule.c
@@ -8,9 +8,8 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/module.c
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
+#include "root/dsystem.h"
+#include "root/rmem.h"
#include "mars.h"
#include "module.h"
@@ -24,14 +23,6 @@
#include "lexer.h"
#include "attrib.h"
-// For getcwd()
-#if _WIN32
-#include <direct.h>
-#endif
-#if POSIX
-#include <unistd.h>
-#endif
-
AggregateDeclaration *Module::moduleinfo;
Module *Module::rootModule;
@@ -193,7 +184,7 @@ void Module::deleteObjFile()
docfile->remove();
}
-const char *Module::kind()
+const char *Module::kind() const
{
return "module";
}
@@ -310,7 +301,8 @@ bool Module::read(Loc loc)
{
::error(loc, "cannot find source code for runtime library file 'object.d'");
errorSupplemental(loc, "dmd might not be correctly installed. Run 'dmd -man' for installation instructions.");
- errorSupplemental(loc, "config file: %s", FileName::canonicalName(global.inifilename));
+ const char *dmdConfFile = FileName::canonicalName(global.inifilename);
+ errorSupplemental(loc, "config file: %s", dmdConfFile ? dmdConfFile : "not found");
}
else
{
@@ -1043,8 +1035,7 @@ void Module::runDeferredSemantic()
}
else
{
- todo = (Dsymbol **)malloc(len * sizeof(Dsymbol *));
- assert(todo);
+ todo = (Dsymbol **)mem.xmalloc(len * sizeof(Dsymbol *));
todoalloc = todo;
}
memcpy(todo, deferred.tdata(), len * sizeof(Dsymbol *));
@@ -1219,7 +1210,7 @@ Package::Package(Identifier *ident)
}
-const char *Package::kind()
+const char *Package::kind() const
{
return "package";
}
diff --git a/gcc/d/dmd/doc.c b/gcc/d/dmd/doc.c
index 92ce33c..d35ca7b 100644
--- a/gcc/d/dmd/doc.c
+++ b/gcc/d/dmd/doc.c
@@ -10,12 +10,7 @@
// This implements the Ddoc capability.
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <ctype.h>
-#include <assert.h>
-
+#include "root/dsystem.h"
#include "root/rmem.h"
#include "root/root.h"
#include "root/port.h"
diff --git a/gcc/d/dmd/doc.h b/gcc/d/dmd/doc.h
index 7f3ef51..d1428fb 100644
--- a/gcc/d/dmd/doc.h
+++ b/gcc/d/dmd/doc.h
@@ -10,5 +10,10 @@
#pragma once
+#include "root/dsystem.h"
+
+class Module;
+struct OutBuffer;
+
void escapeDdocString(OutBuffer *buf, size_t start);
void gendocfile(Module *m);
diff --git a/gcc/d/dmd/dscope.c b/gcc/d/dmd/dscope.c
index 924a376..27412b5 100644
--- a/gcc/d/dmd/dscope.c
+++ b/gcc/d/dmd/dscope.c
@@ -8,10 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/scope.c
*/
-#include <stdio.h>
-#include <assert.h>
-#include <string.h> // strlen()
-
+#include "root/dsystem.h" // strlen()
#include "root/root.h"
#include "root/rmem.h"
#include "root/speller.h"
diff --git a/gcc/d/dmd/dstruct.c b/gcc/d/dmd/dstruct.c
index c99abce..f9f15ba 100644
--- a/gcc/d/dmd/dstruct.c
+++ b/gcc/d/dmd/dstruct.c
@@ -8,10 +8,9 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/struct.c
*/
-#include <stdio.h>
-#include <assert.h>
-
+#include "root/dsystem.h"
#include "root/root.h"
+
#include "errors.h"
#include "aggregate.h"
#include "scope.h"
@@ -1438,7 +1437,7 @@ bool StructDeclaration::isPOD()
return (ispod == ISPODyes);
}
-const char *StructDeclaration::kind()
+const char *StructDeclaration::kind() const
{
return "struct";
}
@@ -1457,7 +1456,7 @@ Dsymbol *UnionDeclaration::syntaxCopy(Dsymbol *s)
return StructDeclaration::syntaxCopy(ud);
}
-const char *UnionDeclaration::kind()
+const char *UnionDeclaration::kind() const
{
return "union";
}
diff --git a/gcc/d/dmd/dsymbol.c b/gcc/d/dmd/dsymbol.c
index 0f0a0dc..b511b79 100644
--- a/gcc/d/dmd/dsymbol.c
+++ b/gcc/d/dmd/dsymbol.c
@@ -8,11 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/dsymbol.c
*/
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <limits.h>
-
+#include "root/dsystem.h"
#include "root/rmem.h"
#include "root/speller.h"
#include "root/aav.h"
@@ -241,9 +237,7 @@ const char *Dsymbol::toPrettyChars(bool QualifyTypes)
++complength;
// Allocate temporary array comp[]
- const char **comp = (const char **)malloc(complength * sizeof(char**));
- if (!comp)
- Mem::error();
+ const char **comp = (const char **)mem.xmalloc(complength * sizeof(char**));
// Fill in comp[] and compute length of final result
size_t length = 0;
@@ -293,7 +287,7 @@ const char *Dsymbol::locToChars()
return getLoc().toChars();
}
-const char *Dsymbol::kind()
+const char *Dsymbol::kind() const
{
return "symbol";
}
@@ -921,7 +915,7 @@ void OverloadSet::push(Dsymbol *s)
a.push(s);
}
-const char *OverloadSet::kind()
+const char *OverloadSet::kind() const
{
return "overloadset";
}
@@ -1273,7 +1267,7 @@ void ScopeDsymbol::multiplyDefined(Loc loc, Dsymbol *s1, Dsymbol *s2)
}
}
-const char *ScopeDsymbol::kind()
+const char *ScopeDsymbol::kind() const
{
return "ScopeDsymbol";
}
diff --git a/gcc/d/dmd/dsymbol.h b/gcc/d/dmd/dsymbol.h
index 0f2f03d..421a043 100644
--- a/gcc/d/dmd/dsymbol.h
+++ b/gcc/d/dmd/dsymbol.h
@@ -193,7 +193,7 @@ public:
virtual Identifier *getIdent();
virtual const char *toPrettyChars(bool QualifyTypes = false);
- virtual const char *kind();
+ virtual const char *kind() const;
virtual Dsymbol *toAlias(); // resolve real symbol
virtual Dsymbol *toAlias2();
virtual int apply(Dsymbol_apply_ft_t fp, void *param);
@@ -309,7 +309,7 @@ public:
virtual bool isPackageAccessible(Package *p, Prot protection, int flags = 0);
bool isforwardRef();
static void multiplyDefined(Loc loc, Dsymbol *s1, Dsymbol *s2);
- const char *kind();
+ const char *kind() const;
FuncDeclaration *findGetMembers();
virtual Dsymbol *symtabInsert(Dsymbol *s);
virtual Dsymbol *symtabLookup(Dsymbol *s, Identifier *id);
@@ -366,7 +366,7 @@ public:
OverloadSet(Identifier *ident, OverloadSet *os = NULL);
void push(Dsymbol *s);
OverloadSet *isOverloadSet() { return this; }
- const char *kind();
+ const char *kind() const;
void accept(Visitor *v) { v->visit(this); }
};
@@ -380,7 +380,7 @@ class ForwardingScopeDsymbol : public ScopeDsymbol
Dsymbol *symtabLookup(Dsymbol *s, Identifier *id);
void importScope(Dsymbol *s, Prot protection);
void semantic(Scope *sc);
- const char *kind();
+ const char *kind() const;
ForwardingScopeDsymbol *isForwardingScopeDsymbol() { return this; }
};
diff --git a/gcc/d/dmd/dtemplate.c b/gcc/d/dmd/dtemplate.c
index f2b3b2f..9455e97 100644
--- a/gcc/d/dmd/dtemplate.c
+++ b/gcc/d/dmd/dtemplate.c
@@ -10,9 +10,7 @@
// Handle template implementation
-#include <stdio.h>
-#include <assert.h>
-
+#include "root/dsystem.h"
#include "root/root.h"
#include "root/aav.h"
#include "root/rmem.h"
@@ -689,7 +687,7 @@ void TemplateDeclaration::semantic(Scope *sc)
*/
}
-const char *TemplateDeclaration::kind()
+const char *TemplateDeclaration::kind() const
{
return (onemember && onemember->isAggregateDeclaration())
? onemember->kind()
@@ -7844,7 +7842,7 @@ Dsymbol *TemplateInstance::toAlias()
return inst;
}
-const char *TemplateInstance::kind()
+const char *TemplateInstance::kind() const
{
return "template instance";
}
@@ -8530,7 +8528,7 @@ void TemplateMixin::semantic3(Scope *sc)
}
}
-const char *TemplateMixin::kind()
+const char *TemplateMixin::kind() const
{
return "mixin";
}
diff --git a/gcc/d/dmd/dversion.c b/gcc/d/dmd/dversion.c
index 4737486..849afaa 100644
--- a/gcc/d/dmd/dversion.c
+++ b/gcc/d/dmd/dversion.c
@@ -8,9 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/version.c
*/
-#include <stdio.h>
-#include <assert.h>
-
+#include "root/dsystem.h"
#include "root/root.h"
#include "identifier.h"
@@ -106,7 +104,7 @@ void DebugSymbol::semantic(Scope *)
semanticRun = PASSsemanticdone;
}
-const char *DebugSymbol::kind()
+const char *DebugSymbol::kind() const
{
return "debug";
}
@@ -196,7 +194,7 @@ void VersionSymbol::semantic(Scope *)
semanticRun = PASSsemanticdone;
}
-const char *VersionSymbol::kind()
+const char *VersionSymbol::kind() const
{
return "version";
}
diff --git a/gcc/d/dmd/entity.c b/gcc/d/dmd/entity.c
index 38fd2d8..78abc8f 100644
--- a/gcc/d/dmd/entity.c
+++ b/gcc/d/dmd/entity.c
@@ -8,9 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/entity.c
*/
-#include <string.h>
-#include <ctype.h>
-
+#include "root/dsystem.h"
#include "root/port.h"
/*********************************************
diff --git a/gcc/d/dmd/enum.h b/gcc/d/dmd/enum.h
index 072eacf..ce50057 100644
--- a/gcc/d/dmd/enum.h
+++ b/gcc/d/dmd/enum.h
@@ -50,7 +50,7 @@ public:
void semantic(Scope *sc);
bool oneMember(Dsymbol **ps, Identifier *ident);
Type *getType();
- const char *kind();
+ const char *kind() const;
Dsymbol *search(const Loc &loc, Identifier *ident, int flags = SearchLocalsOnly);
bool isDeprecated(); // is Dsymbol deprecated?
Prot prot();
@@ -86,7 +86,7 @@ public:
EnumMember(Loc loc, Identifier *id, Expression *value, Type *origType);
Dsymbol *syntaxCopy(Dsymbol *s);
- const char *kind();
+ const char *kind() const;
void semantic(Scope *sc);
Expression *getVarExp(Loc loc, Scope *sc);
diff --git a/gcc/d/dmd/errors.h b/gcc/d/dmd/errors.h
index 7b3ebc0..42cc1d7 100644
--- a/gcc/d/dmd/errors.h
+++ b/gcc/d/dmd/errors.h
@@ -10,6 +10,7 @@
#pragma once
+#include "root/dsystem.h"
#include "globals.h"
bool isConsoleColorSupported();
diff --git a/gcc/d/dmd/expression.c b/gcc/d/dmd/expression.c
index dc0d8e7..359e4cc 100644
--- a/gcc/d/dmd/expression.c
+++ b/gcc/d/dmd/expression.c
@@ -8,12 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/expression.c
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <math.h>
-#include <assert.h>
-
+#include "root/dsystem.h"
#include "root/rmem.h"
#include "root/root.h"
diff --git a/gcc/d/dmd/expression.h b/gcc/d/dmd/expression.h
index 57c516c..27a153e 100644
--- a/gcc/d/dmd/expression.h
+++ b/gcc/d/dmd/expression.h
@@ -1490,6 +1490,14 @@ struct UnionExp
Expression *copy();
private:
+ // Ensure that the union is suitably aligned.
+#if defined(__GNUC__) || defined(__clang__)
+ __attribute__((aligned(8)))
+#elif defined(_MSC_VER)
+ __declspec(align(8))
+#elif defined(__DMC__)
+ #pragma pack(8)
+#endif
union
{
char exp [sizeof(Expression)];
@@ -1507,10 +1515,10 @@ private:
char addrexp [sizeof(AddrExp)];
char indexexp [sizeof(IndexExp)];
char sliceexp [sizeof(SliceExp)];
-
- // Ensure that the union is suitably aligned.
- real_t for_alignment_only;
} u;
+#if defined(__DMC__)
+ #pragma pack()
+#endif
};
/****************************************************************/
diff --git a/gcc/d/dmd/expressionsem.c b/gcc/d/dmd/expressionsem.c
index 247d143..96ae7ef 100644
--- a/gcc/d/dmd/expressionsem.c
+++ b/gcc/d/dmd/expressionsem.c
@@ -7,12 +7,7 @@
* http://www.boost.org/LICENSE_1_0.txt
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <math.h>
-#include <assert.h>
-
+#include "root/dsystem.h"
#include "root/rmem.h"
#include "root/root.h"
diff --git a/gcc/d/dmd/func.c b/gcc/d/dmd/func.c
index 2feea91..c8f9c5c 100644
--- a/gcc/d/dmd/func.c
+++ b/gcc/d/dmd/func.c
@@ -8,8 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/func.c
*/
-#include <stdio.h>
-#include <assert.h>
+#include "root/dsystem.h"
#include "mars.h"
#include "init.h"
@@ -4254,7 +4253,7 @@ void FuncDeclaration::checkDmain()
error("parameters must be main() or main(string[] args)");
}
-const char *FuncDeclaration::kind()
+const char *FuncDeclaration::kind() const
{
return generated ? "generated function" : "function";
}
@@ -4645,7 +4644,7 @@ FuncAliasDeclaration::FuncAliasDeclaration(Identifier *ident, FuncDeclaration *f
userAttribDecl = funcalias->userAttribDecl;
}
-const char *FuncAliasDeclaration::kind()
+const char *FuncAliasDeclaration::kind() const
{
return "function alias";
}
@@ -4756,7 +4755,7 @@ void FuncLiteralDeclaration::modifyReturns(Scope *sc, Type *tret)
((TypeFunction *)type)->next = tret;
}
-const char *FuncLiteralDeclaration::kind()
+const char *FuncLiteralDeclaration::kind() const
{
return (tok != TOKfunction) ? "delegate" : "function";
}
@@ -4869,7 +4868,7 @@ void CtorDeclaration::semantic(Scope *sc)
}
}
-const char *CtorDeclaration::kind()
+const char *CtorDeclaration::kind() const
{
return "constructor";
}
@@ -5039,7 +5038,7 @@ bool DtorDeclaration::addPostInvariant()
return false;
}
-const char *DtorDeclaration::kind()
+const char *DtorDeclaration::kind() const
{
return "destructor";
}
@@ -5521,7 +5520,7 @@ void NewDeclaration::semantic(Scope *sc)
FuncDeclaration::semantic(sc);
}
-const char *NewDeclaration::kind()
+const char *NewDeclaration::kind() const
{
return "allocator";
}
@@ -5600,7 +5599,7 @@ void DeleteDeclaration::semantic(Scope *sc)
FuncDeclaration::semantic(sc);
}
-const char *DeleteDeclaration::kind()
+const char *DeleteDeclaration::kind() const
{
return "deallocator";
}
diff --git a/gcc/d/dmd/globals.h b/gcc/d/dmd/globals.h
index 63caeb7..e5fefe9 100644
--- a/gcc/d/dmd/globals.h
+++ b/gcc/d/dmd/globals.h
@@ -234,22 +234,13 @@ struct Global
extern Global global;
-// Because int64_t and friends may be any integral type of the
-// correct size, we have to explicitly ask for the correct
-// integer type to get the correct mangling with ddmd
-#if __LP64__
// Be careful not to care about sign when using dinteger_t
// use this instead of integer_t to
// avoid conflicts with system #include's
-typedef unsigned long dinteger_t;
+typedef uint64_t dinteger_t;
// Signed and unsigned variants
-typedef long sinteger_t;
-typedef unsigned long uinteger_t;
-#else
-typedef unsigned long long dinteger_t;
-typedef long long sinteger_t;
-typedef unsigned long long uinteger_t;
-#endif
+typedef int64_t sinteger_t;
+typedef uint64_t uinteger_t;
typedef int8_t d_int8;
typedef uint8_t d_uns8;
diff --git a/gcc/d/dmd/hdrgen.c b/gcc/d/dmd/hdrgen.c
index 2c734b3..a1f3c12 100644
--- a/gcc/d/dmd/hdrgen.c
+++ b/gcc/d/dmd/hdrgen.c
@@ -10,11 +10,7 @@
// Routines to emit header files
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
+#include "root/dsystem.h"
#include "root/rmem.h"
#include "mars.h"
@@ -2336,7 +2332,8 @@ public:
(ie, 8 chars more than mantissa). Plus one for trailing \0.
Plus one for rounding. */
const size_t BUFFER_LEN = sizeof(value) * 3 + 8 + 1 + 1;
- char buffer[BUFFER_LEN] = {};
+ char buffer[BUFFER_LEN];
+ memset(buffer, 0, BUFFER_LEN);
CTFloat::sprint(buffer, 'g', value);
assert(strlen(buffer) < BUFFER_LEN);
diff --git a/gcc/d/dmd/hdrgen.h b/gcc/d/dmd/hdrgen.h
index c4bafca..f9178be 100644
--- a/gcc/d/dmd/hdrgen.h
+++ b/gcc/d/dmd/hdrgen.h
@@ -10,8 +10,7 @@
#pragma once
-#include <string.h> // memset()
-
+#include "root/dsystem.h" // memset()
#include "dsymbol.h"
void genhdrfile(Module *m);
diff --git a/gcc/d/dmd/identifier.c b/gcc/d/dmd/identifier.c
index 5e40746..f535e5b 100644
--- a/gcc/d/dmd/identifier.c
+++ b/gcc/d/dmd/identifier.c
@@ -8,11 +8,9 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/identifier.c
*/
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-
+#include "root/dsystem.h"
#include "root/root.h"
+
#include "identifier.h"
#include "mars.h"
#include "id.h"
diff --git a/gcc/d/dmd/idgen.c b/gcc/d/dmd/idgen.c
index d360ec8..d07725b 100644
--- a/gcc/d/dmd/idgen.c
+++ b/gcc/d/dmd/idgen.c
@@ -14,10 +14,7 @@
// id.h
// id.c
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
+#include "root/dsystem.h"
struct Msgtable
{
diff --git a/gcc/d/dmd/impcnvgen.c b/gcc/d/dmd/impcnvgen.c
index 5b88e8e..15239fd 100644
--- a/gcc/d/dmd/impcnvgen.c
+++ b/gcc/d/dmd/impcnvgen.c
@@ -8,8 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/impcnvgen.c
*/
-#include <stdio.h>
-#include <stdlib.h>
+#include "root/dsystem.h"
#include "mtype.h"
diff --git a/gcc/d/dmd/imphint.c b/gcc/d/dmd/imphint.c
index 6d75603..9b29490 100644
--- a/gcc/d/dmd/imphint.c
+++ b/gcc/d/dmd/imphint.c
@@ -9,11 +9,7 @@
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <assert.h>
-#include <string.h>
+#include "root/dsystem.h"
#include "mars.h"
diff --git a/gcc/d/dmd/import.h b/gcc/d/dmd/import.h
index e0fa14d..dcaec5c 100644
--- a/gcc/d/dmd/import.h
+++ b/gcc/d/dmd/import.h
@@ -42,7 +42,7 @@ public:
Import(Loc loc, Identifiers *packages, Identifier *id, Identifier *aliasId,
int isstatic);
void addAlias(Identifier *name, Identifier *alias);
- const char *kind();
+ const char *kind() const;
Prot prot();
Dsymbol *syntaxCopy(Dsymbol *s); // copy only syntax trees
void load(Scope *sc);
diff --git a/gcc/d/dmd/init.c b/gcc/d/dmd/init.c
index e619cb4..6603f66 100644
--- a/gcc/d/dmd/init.c
+++ b/gcc/d/dmd/init.c
@@ -8,10 +8,9 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/init.c
*/
-#include <stdio.h>
-#include <assert.h>
+#include "root/dsystem.h"
+#include "root/checkedint.h"
-#include "checkedint.h"
#include "mars.h"
#include "init.h"
#include "expression.h"
diff --git a/gcc/d/dmd/initsem.c b/gcc/d/dmd/initsem.c
index bdaf253..bcb620d 100644
--- a/gcc/d/dmd/initsem.c
+++ b/gcc/d/dmd/initsem.c
@@ -7,7 +7,7 @@
* http://www.boost.org/LICENSE_1_0.txt
*/
-#include "checkedint.h"
+#include "root/checkedint.h"
#include "mars.h"
#include "init.h"
#include "expression.h"
diff --git a/gcc/d/dmd/intrange.c b/gcc/d/dmd/intrange.c
index b4d54db..966b9a2 100644
--- a/gcc/d/dmd/intrange.c
+++ b/gcc/d/dmd/intrange.c
@@ -8,8 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/intrange.c
*/
-#include <stddef.h>
-#include <stdint.h>
+#include "root/dsystem.h"
#include "intrange.h"
#include "mars.h"
diff --git a/gcc/d/dmd/json.c b/gcc/d/dmd/json.c
index 4c49023..5ee9571 100644
--- a/gcc/d/dmd/json.c
+++ b/gcc/d/dmd/json.c
@@ -10,10 +10,7 @@
// This implements the JSON capability.
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
+#include "root/dsystem.h"
#include "root/rmem.h"
#include "mars.h"
diff --git a/gcc/d/dmd/lexer.c b/gcc/d/dmd/lexer.c
index 1fefe2b..0b18245 100644
--- a/gcc/d/dmd/lexer.c
+++ b/gcc/d/dmd/lexer.c
@@ -10,16 +10,7 @@
/* Lexical Analyzer */
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <wchar.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <time.h> // for time() and ctime()
-
+#include "root/dsystem.h" // for time() and ctime()
#include "root/rmem.h"
#include "mars.h"
diff --git a/gcc/d/dmd/macro.h b/gcc/d/dmd/macro.h
index 006f118..f44108b1 100644
--- a/gcc/d/dmd/macro.h
+++ b/gcc/d/dmd/macro.h
@@ -10,11 +10,7 @@
#pragma once
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <ctype.h>
-
+#include "root/dsystem.h"
#include "root/root.h"
diff --git a/gcc/d/dmd/mars.h b/gcc/d/dmd/mars.h
index 9cc5bb8..5aec7e6 100644
--- a/gcc/d/dmd/mars.h
+++ b/gcc/d/dmd/mars.h
@@ -54,9 +54,7 @@ the target object file format:
*/
-#include <stdio.h>
-#include <stdint.h>
-#include <stdarg.h>
+#include "root/dsystem.h"
#ifdef __DMC__
#ifdef DEBUG
diff --git a/gcc/d/dmd/module.h b/gcc/d/dmd/module.h
index 399b008..d8fb020 100644
--- a/gcc/d/dmd/module.h
+++ b/gcc/d/dmd/module.h
@@ -35,7 +35,7 @@ public:
Module *mod; // != NULL if isPkgMod == PKGmodule
Package(Identifier *ident);
- const char *kind();
+ const char *kind() const;
static DsymbolTable *resolve(Identifiers *packages, Dsymbol **pparent, Package **ppkg);
@@ -117,7 +117,7 @@ public:
static Module *load(Loc loc, Identifiers *packages, Identifier *ident);
- const char *kind();
+ const char *kind() const;
File *setOutfile(const char *name, const char *dir, const char *arg, const char *ext);
void setDocfile();
bool read(Loc loc); // read file, returns 'true' if succeed, 'false' otherwise.
diff --git a/gcc/d/dmd/mtype.c b/gcc/d/dmd/mtype.c
index a4c38e8..dedaf7d 100644
--- a/gcc/d/dmd/mtype.c
+++ b/gcc/d/dmd/mtype.c
@@ -8,22 +8,8 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/mtype.c
*/
-#define __C99FEATURES__ 1 // Needed on Solaris for NaN and more
-#define __USE_ISOC99 1 // so signbit() gets defined
-
-#include <math.h>
-#include <stdio.h>
-#include <assert.h>
-#include <float.h>
-
-#if _MSC_VER
-#include <malloc.h>
-#include <limits>
-#elif __MINGW32__
-#include <malloc.h>
-#endif
-
-#include "checkedint.h"
+#include "root/dsystem.h"
+#include "root/checkedint.h"
#include "root/rmem.h"
#include "mars.h"
@@ -2336,8 +2322,7 @@ Identifier *Type::getTypeInfoIdent()
// Allocate buffer on stack, fail over to using malloc()
char namebuf[128];
size_t namelen = 19 + sizeof(len) * 3 + len + 1;
- char *name = namelen <= sizeof(namebuf) ? namebuf : (char *)malloc(namelen);
- assert(name);
+ char *name = namelen <= sizeof(namebuf) ? namebuf : (char *)mem.xmalloc(namelen);
sprintf(name, "_D%lluTypeInfo_%s6__initZ", (unsigned long long) 9 + len, buf.data);
//printf("%p, deco = %s, name = %s\n", this, deco, name);
@@ -9343,20 +9328,23 @@ bool Parameter::isCovariantScope(bool returnByRef, StorageClass from, StorageCla
static unsigned buildSR(bool returnByRef, StorageClass stc)
{
unsigned result;
- switch (stc & (STCref | STCscope | STCreturn))
- {
- case 0: result = SRNone; break;
- case STCref: result = SRRef; break;
- case STCscope: result = SRScope; break;
- case STCreturn | STCref: result = SRReturnRef; break;
- case STCreturn | STCscope: result = SRReturnScope; break;
- case STCref | STCscope: result = SRRefScope; break;
- case STCreturn | STCref | STCscope:
- result = returnByRef ? SRReturnRef_Scope : SRRef_ReturnScope;
- break;
- default:
- assert(0);
- }
+ StorageClass stc2 = stc & (STCref | STCscope | STCreturn);
+ if (stc2 == 0)
+ result = SRNone;
+ else if (stc2 == STCref)
+ result = SRRef;
+ else if (stc2 == STCscope)
+ result = SRScope;
+ else if (stc2 == (STCscope | STCreturn))
+ result = SRReturnScope;
+ else if (stc2 == (STCref | STCreturn))
+ result = SRReturnRef;
+ else if (stc2 == (STCscope | STCref))
+ result = SRRefScope;
+ else if (stc2 == (STCscope | STCref | STCreturn))
+ result = returnByRef ? SRReturnRef_Scope : SRRef_ReturnScope;
+ else
+ assert(0);
return result;
}
diff --git a/gcc/d/dmd/nspace.c b/gcc/d/dmd/nspace.c
index 2bd6b96..49c41f3 100644
--- a/gcc/d/dmd/nspace.c
+++ b/gcc/d/dmd/nspace.c
@@ -6,9 +6,7 @@
// Source: https://github.com/D-Programming-Language/dmd/blob/master/src/nspace.c
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
+#include "root/dsystem.h"
#include "mars.h"
#include "dsymbol.h"
@@ -156,7 +154,7 @@ void Nspace::semantic3(Scope *sc)
}
}
-const char *Nspace::kind()
+const char *Nspace::kind() const
{
return "namespace";
}
diff --git a/gcc/d/dmd/nspace.h b/gcc/d/dmd/nspace.h
index 8ca01ae..f6c4a3d 100644
--- a/gcc/d/dmd/nspace.h
+++ b/gcc/d/dmd/nspace.h
@@ -32,7 +32,7 @@ class Nspace : public ScopeDsymbol
int apply(Dsymbol_apply_ft_t fp, void *param);
bool hasPointers();
void setFieldOffset(AggregateDeclaration *ad, unsigned *poffset, bool isunion);
- const char *kind();
+ const char *kind() const;
Nspace *isNspace() { return this; }
void accept(Visitor *v) { v->visit(this); }
};
diff --git a/gcc/d/dmd/opover.c b/gcc/d/dmd/opover.c
index be6fd78..0bcccb6 100644
--- a/gcc/d/dmd/opover.c
+++ b/gcc/d/dmd/opover.c
@@ -8,12 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/opover.c
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <assert.h>
-#include <string.h> // memset()
-
+#include "root/dsystem.h" // memset()
#include "root/rmem.h"
#include "mars.h"
diff --git a/gcc/d/dmd/optimize.c b/gcc/d/dmd/optimize.c
index 12224fa..89a584b 100644
--- a/gcc/d/dmd/optimize.c
+++ b/gcc/d/dmd/optimize.c
@@ -8,12 +8,9 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/optimize.c
*/
-#include <stdio.h>
-#include <ctype.h>
-#include <assert.h>
-#include <math.h>
+#include "root/dsystem.h"
-#include "checkedint.h"
+#include "root/checkedint.h"
#include "lexer.h"
#include "mtype.h"
#include "expression.h"
diff --git a/gcc/d/dmd/parse.c b/gcc/d/dmd/parse.c
index 9ee2f08..1198760 100644
--- a/gcc/d/dmd/parse.c
+++ b/gcc/d/dmd/parse.c
@@ -10,11 +10,9 @@
// This is the D parser
-#include <stdio.h>
-#include <assert.h>
-#include <string.h> // strlen(),memcpy()
-
+#include "root/dsystem.h" // strlen(),memcpy()
#include "root/rmem.h"
+
#include "mars.h"
#include "lexer.h"
#include "parse.h"
diff --git a/gcc/d/dmd/parse.h b/gcc/d/dmd/parse.h
index 5038106..92c09de 100644
--- a/gcc/d/dmd/parse.h
+++ b/gcc/d/dmd/parse.h
@@ -52,7 +52,7 @@ enum ParseStatementFlags
PSscope = 2, // start a new scope
PScurly = 4, // { } statement is required
PScurlyscope = 8, // { } starts a new scope
- PSsemi_ok = 0x10, // empty ';' are really ok
+ PSsemi_ok = 0x10 // empty ';' are really ok
};
@@ -180,7 +180,7 @@ enum PREC
PREC_mul,
PREC_pow,
PREC_unary,
- PREC_primary,
+ PREC_primary
};
extern PREC precedence[TOKMAX];
diff --git a/gcc/d/dmd/root/aav.c b/gcc/d/dmd/root/aav.c
index 4c015bf..931a395 100644
--- a/gcc/d/dmd/root/aav.c
+++ b/gcc/d/dmd/root/aav.c
@@ -11,11 +11,7 @@
*
*/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-
+#include "dsystem.h"
#include "aav.h"
#include "rmem.h"
diff --git a/gcc/d/dmd/root/aav.h b/gcc/d/dmd/root/aav.h
index 24c281a..ad57cb4 100644
--- a/gcc/d/dmd/root/aav.h
+++ b/gcc/d/dmd/root/aav.h
@@ -8,6 +8,8 @@
#pragma once
+#include "dsystem.h"
+
typedef void* Value;
typedef void* Key;
diff --git a/gcc/d/dmd/root/array.h b/gcc/d/dmd/root/array.h
index ed128b9..dd28998 100644
--- a/gcc/d/dmd/root/array.h
+++ b/gcc/d/dmd/root/array.h
@@ -7,11 +7,7 @@
#pragma once
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
+#include "dsystem.h"
#include "object.h"
#include "rmem.h"
diff --git a/gcc/d/dmd/checkedint.c b/gcc/d/dmd/root/checkedint.c
index b9ccb5b..392904a 100644
--- a/gcc/d/dmd/checkedint.c
+++ b/gcc/d/dmd/root/checkedint.c
@@ -24,13 +24,13 @@
* Copyright: Copyright (C) 2014-2018 by The D Language Foundation, All Rights Reserved
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Authors: Walter Bright
- * Source: https://github.com/D-Programming-Language/dmd/blob/master/src/root/port.c
+ * Source: https://github.com/D-Programming-Language/dmd/blob/master/src/root/checkedint.c
*/
-#include <assert.h>
-
+#include "dsystem.h"
#include "checkedint.h"
+
/*******************************
* Add two signed integers, checking for overflow.
*
diff --git a/gcc/d/dmd/checkedint.h b/gcc/d/dmd/root/checkedint.h
index 1f6545b..1362ff5 100644
--- a/gcc/d/dmd/checkedint.h
+++ b/gcc/d/dmd/root/checkedint.h
@@ -5,15 +5,10 @@
* http://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
* http://www.boost.org/LICENSE_1_0.txt
- * https://github.com/D-Programming-Language/dmd/blob/master/src/checkedint.h
+ * https://github.com/D-Programming-Language/dmd/blob/master/src/root/checkedint.h
*/
-#pragma once
-
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS 1
-#endif
-#include <stdint.h>
+#include "dsystem.h"
int adds(int x, int y, bool& overflow);
diff --git a/gcc/d/dmd/root/dcompat.h b/gcc/d/dmd/root/dcompat.h
index 3fc169c..f92f0ab 100644
--- a/gcc/d/dmd/root/dcompat.h
+++ b/gcc/d/dmd/root/dcompat.h
@@ -9,6 +9,8 @@
#pragma once
+#include "dsystem.h"
+
/// Represents a D [ ] array
template<typename T>
struct DArray
diff --git a/gcc/d/dmd/root/dsystem.h b/gcc/d/dmd/root/dsystem.h
new file mode 100644
index 0000000..940ff50
--- /dev/null
+++ b/gcc/d/dmd/root/dsystem.h
@@ -0,0 +1,24 @@
+/* dsystem.h -- Get common system includes from the host.
+ * 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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+/* This header is used in place of dmd upstream so that we can wrap
+ around gcc's system.h. */
+
+#pragma once
+
+#include "d-system.h"
diff --git a/gcc/d/dmd/root/file.c b/gcc/d/dmd/root/file.c
index f4fd51a..454d4cb 100644
--- a/gcc/d/dmd/root/file.c
+++ b/gcc/d/dmd/root/file.c
@@ -6,29 +6,14 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/root/file.c
*/
+#include "dsystem.h"
#include "file.h"
-#if defined (__sun)
-#include <alloca.h>
-#endif
-
-#if _MSC_VER ||__MINGW32__
-#include <malloc.h>
-#include <string>
-#endif
-
#if _WIN32
#include <windows.h>
-#include <direct.h>
-#include <errno.h>
#endif
#if POSIX
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
#include <utime.h>
#endif
@@ -104,7 +89,11 @@ bool File::read()
goto err2;
}
size = (size_t)buf.st_size;
+#ifdef IN_GCC
+ buffer = (unsigned char *) ::xmalloc(size + 2);
+#else
buffer = (unsigned char *) ::malloc(size + 2);
+#endif
if (!buffer)
{
printf("\tmalloc error, errno = %d\n",errno);
@@ -155,7 +144,11 @@ err1:
ref = 0;
size = GetFileSize(h,NULL);
+#ifdef IN_GCC
+ buffer = (unsigned char *) ::xmalloc(size + 2);
+#else
buffer = (unsigned char *) ::malloc(size + 2);
+#endif
if (!buffer)
goto err2;
diff --git a/gcc/d/dmd/root/file.h b/gcc/d/dmd/root/file.h
index f6953ab..f4d2937 100644
--- a/gcc/d/dmd/root/file.h
+++ b/gcc/d/dmd/root/file.h
@@ -8,8 +8,7 @@
#pragma once
-#include <stddef.h>
-
+#include "dsystem.h"
#include "array.h"
typedef Array<struct File *> Files;
diff --git a/gcc/d/dmd/root/filename.c b/gcc/d/dmd/root/filename.c
index 307e94f..b0bd1a5 100644
--- a/gcc/d/dmd/root/filename.c
+++ b/gcc/d/dmd/root/filename.c
@@ -6,37 +6,19 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/root/filename.c
*/
+#include "dsystem.h"
#include "filename.h"
-#include <stdint.h>
-#include <ctype.h>
-
#include "outbuffer.h"
#include "array.h"
#include "file.h"
#include "rmem.h"
-#if defined (__sun)
-#include <alloca.h>
-#endif
-
-#if _MSC_VER ||__MINGW32__
-#include <malloc.h>
-#include <string>
-#endif
-
#if _WIN32
#include <windows.h>
-#include <direct.h>
-#include <errno.h>
#endif
#if POSIX
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
#include <utime.h>
#endif
diff --git a/gcc/d/dmd/root/hash.h b/gcc/d/dmd/root/hash.h
index 1b05672..f1bc6cc 100644
--- a/gcc/d/dmd/root/hash.h
+++ b/gcc/d/dmd/root/hash.h
@@ -10,8 +10,7 @@
#pragma once
-#include <stdint.h> // uint{8|16|32}_t
-#include <stdlib.h>
+#include "dsystem.h" // uint{8|16|32}_t
// MurmurHash2 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
diff --git a/gcc/d/dmd/root/object.h b/gcc/d/dmd/root/object.h
index e9d770d..d465e36 100644
--- a/gcc/d/dmd/root/object.h
+++ b/gcc/d/dmd/root/object.h
@@ -6,11 +6,9 @@
* https://github.com/dlang/dmd/blob/master/src/root/object.h
*/
-#define POSIX (__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun)
-
#pragma once
-#include <stddef.h>
+#include "dsystem.h"
typedef size_t hash_t;
@@ -25,7 +23,7 @@ enum DYNCAST
DYNCAST_IDENTIFIER,
DYNCAST_TUPLE,
DYNCAST_PARAMETER,
- DYNCAST_STATEMENT,
+ DYNCAST_STATEMENT
};
/*
diff --git a/gcc/d/dmd/root/outbuffer.c b/gcc/d/dmd/root/outbuffer.c
index 7b6782d..4791bb1 100644
--- a/gcc/d/dmd/root/outbuffer.c
+++ b/gcc/d/dmd/root/outbuffer.c
@@ -6,16 +6,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/root/outbuffer.c
*/
-#include <assert.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if __sun
-#include <alloca.h>
-#endif
-
+#include "dsystem.h"
#include "outbuffer.h"
#include "object.h"
diff --git a/gcc/d/dmd/root/outbuffer.h b/gcc/d/dmd/root/outbuffer.h
index 6d3be10..6e6b35d 100644
--- a/gcc/d/dmd/root/outbuffer.h
+++ b/gcc/d/dmd/root/outbuffer.h
@@ -8,10 +8,7 @@
#pragma once
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <assert.h>
+#include "dsystem.h"
#include "port.h"
#include "rmem.h"
diff --git a/gcc/d/dmd/root/port.h b/gcc/d/dmd/root/port.h
index 3f3c46d..0dbb319 100644
--- a/gcc/d/dmd/root/port.h
+++ b/gcc/d/dmd/root/port.h
@@ -11,11 +11,9 @@
// Portable wrapper around compiler/system specific things.
// The idea is to minimize #ifdef's in the app code.
-#include <stdlib.h> // for alloca
-#include <stdint.h>
+#include "dsystem.h" // for alloca
#if _MSC_VER
-#include <alloca.h>
typedef __int64 longlong;
typedef unsigned __int64 ulonglong;
#else
diff --git a/gcc/d/dmd/root/rmem.c b/gcc/d/dmd/root/rmem.c
index 92e79ca..d24e012 100644
--- a/gcc/d/dmd/root/rmem.c
+++ b/gcc/d/dmd/root/rmem.c
@@ -6,10 +6,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/root/rmem.c
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
+#include "dsystem.h"
#include "rmem.h"
/* This implementation of the storage allocator uses the standard C allocation package.
@@ -23,7 +20,11 @@ char *Mem::xstrdup(const char *s)
if (s)
{
+#ifdef IN_GCC
+ p = ::xstrdup(s);
+#else
p = strdup(s);
+#endif
if (p)
return p;
error();
@@ -38,7 +39,11 @@ void *Mem::xmalloc(size_t size)
p = NULL;
else
{
+#ifdef IN_GCC
+ p = ::xmalloc(size);
+#else
p = malloc(size);
+#endif
if (!p)
error();
}
@@ -52,7 +57,11 @@ void *Mem::xcalloc(size_t size, size_t n)
p = NULL;
else
{
+#ifdef IN_GCC
+ p = ::xcalloc(size, n);
+#else
p = calloc(size, n);
+#endif
if (!p)
error();
}
@@ -70,14 +79,22 @@ void *Mem::xrealloc(void *p, size_t size)
}
else if (!p)
{
+#ifdef IN_GCC
+ p = ::xmalloc(size);
+#else
p = malloc(size);
+#endif
if (!p)
error();
}
else
{
void *psave = p;
+#ifdef IN_GCC
+ p = ::xrealloc(psave, size);
+#else
p = realloc(psave, size);
+#endif
if (!p)
{ xfree(psave);
error();
@@ -99,7 +116,11 @@ void *Mem::xmallocdup(void *o, size_t size)
p = NULL;
else
{
+#ifdef IN_GCC
+ p = ::xmalloc(size);
+#else
p = malloc(size);
+#endif
if (!p)
error();
else
@@ -143,7 +164,11 @@ extern "C" void *allocmemory(size_t m_size)
if (m_size > CHUNK_SIZE)
{
+#ifdef IN_GCC
+ void *p = xmalloc(m_size);
+#else
void *p = malloc(m_size);
+#endif
if (p)
return p;
printf("Error: out of memory\n");
@@ -152,7 +177,11 @@ extern "C" void *allocmemory(size_t m_size)
}
heapleft = CHUNK_SIZE;
+#ifdef IN_GCC
+ heapp = xmalloc(CHUNK_SIZE);
+#else
heapp = malloc(CHUNK_SIZE);
+#endif
if (!heapp)
{
printf("Error: out of memory\n");
diff --git a/gcc/d/dmd/root/rmem.h b/gcc/d/dmd/root/rmem.h
index 87d465f..0123402 100644
--- a/gcc/d/dmd/root/rmem.h
+++ b/gcc/d/dmd/root/rmem.h
@@ -8,7 +8,7 @@
#pragma once
-#include <stddef.h> // for size_t
+#include "dsystem.h" // for size_t
#if __APPLE__ && __i386__
/* size_t is 'unsigned long', which makes it mangle differently
diff --git a/gcc/d/dmd/root/rootobject.c b/gcc/d/dmd/root/rootobject.c
index cd239d6..b45e795 100644
--- a/gcc/d/dmd/root/rootobject.c
+++ b/gcc/d/dmd/root/rootobject.c
@@ -5,8 +5,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/root/object.c
*/
-#include <stdio.h>
-
+#include "dsystem.h"
#include "object.h"
#include "outbuffer.h"
diff --git a/gcc/d/dmd/root/speller.c b/gcc/d/dmd/root/speller.c
index 52b4e47..a5c16ba 100644
--- a/gcc/d/dmd/root/speller.c
+++ b/gcc/d/dmd/root/speller.c
@@ -6,16 +6,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/root/speller.c
*/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <limits.h>
-
-#if __sun || _MSC_VER
-#include <alloca.h>
-#endif
-
+#include "dsystem.h"
#include "speller.h"
const char idchars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
diff --git a/gcc/d/dmd/root/stringtable.c b/gcc/d/dmd/root/stringtable.c
index 158e2af..473df7c 100644
--- a/gcc/d/dmd/root/stringtable.c
+++ b/gcc/d/dmd/root/stringtable.c
@@ -6,11 +6,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/root/stringtable.c
*/
-#include <stdio.h>
-#include <stdint.h> // uint{8|16|32}_t
-#include <string.h> // memcpy()
-#include <stdlib.h>
-
+#include "dsystem.h" // uint{8|16|32}_t, memcpy()
#include "root.h"
#include "rmem.h" // mem
#include "stringtable.h"
diff --git a/gcc/d/dmd/sapply.c b/gcc/d/dmd/sapply.c
index 8920977..18689c1 100644
--- a/gcc/d/dmd/sapply.c
+++ b/gcc/d/dmd/sapply.c
@@ -8,8 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/sapply.c
*/
-#include <stdio.h>
-#include <assert.h>
+#include "root/dsystem.h"
#include "mars.h"
#include "statement.h"
diff --git a/gcc/d/dmd/sideeffect.c b/gcc/d/dmd/sideeffect.c
index 83e7973..56d7d07 100644
--- a/gcc/d/dmd/sideeffect.c
+++ b/gcc/d/dmd/sideeffect.c
@@ -8,8 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/sideeffect.c
*/
-#include <stdio.h>
-#include <assert.h>
+#include "root/dsystem.h"
#include "mars.h"
#include "init.h"
diff --git a/gcc/d/dmd/statement.c b/gcc/d/dmd/statement.c
index 6e67907..5617914 100644
--- a/gcc/d/dmd/statement.c
+++ b/gcc/d/dmd/statement.c
@@ -8,9 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/statement.c
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
+#include "root/dsystem.h"
#include "statement.h"
#include "errors.h"
diff --git a/gcc/d/dmd/statementsem.c b/gcc/d/dmd/statementsem.c
index 7ee541c..9be934f 100644
--- a/gcc/d/dmd/statementsem.c
+++ b/gcc/d/dmd/statementsem.c
@@ -7,12 +7,9 @@
* http://www.boost.org/LICENSE_1_0.txt
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
+#include "root/dsystem.h"
#include "root/rmem.h"
-#include "checkedint.h"
+#include "root/checkedint.h"
#include "errors.h"
#include "statement.h"
diff --git a/gcc/d/dmd/staticassert.c b/gcc/d/dmd/staticassert.c
index 476668f..5da1f7d 100644
--- a/gcc/d/dmd/staticassert.c
+++ b/gcc/d/dmd/staticassert.c
@@ -8,9 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/staticassert.c
*/
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
+#include "root/dsystem.h"
#include "mars.h"
#include "dsymbol.h"
@@ -98,7 +96,7 @@ bool StaticAssert::oneMember(Dsymbol **ps, Identifier *)
return true;
}
-const char *StaticAssert::kind()
+const char *StaticAssert::kind() const
{
return "static assert";
}
diff --git a/gcc/d/dmd/staticassert.h b/gcc/d/dmd/staticassert.h
index 0112f02..4a601ab 100644
--- a/gcc/d/dmd/staticassert.h
+++ b/gcc/d/dmd/staticassert.h
@@ -27,6 +27,6 @@ public:
void semantic(Scope *sc);
void semantic2(Scope *sc);
bool oneMember(Dsymbol **ps, Identifier *ident);
- const char *kind();
+ const char *kind() const;
void accept(Visitor *v) { v->visit(this); }
};
diff --git a/gcc/d/dmd/target.h b/gcc/d/dmd/target.h
index 9379008..63dfcf26 100644
--- a/gcc/d/dmd/target.h
+++ b/gcc/d/dmd/target.h
@@ -19,6 +19,7 @@
class ClassDeclaration;
class Dsymbol;
class Expression;
+class Parameter;
class Type;
struct OutBuffer;
diff --git a/gcc/d/dmd/template.h b/gcc/d/dmd/template.h
index f599103..c913b2a 100644
--- a/gcc/d/dmd/template.h
+++ b/gcc/d/dmd/template.h
@@ -83,7 +83,7 @@ public:
void semantic(Scope *sc);
bool overloadInsert(Dsymbol *s);
bool hasStaticCtorOrDtor();
- const char *kind();
+ const char *kind() const;
const char *toChars();
Prot prot();
@@ -331,7 +331,7 @@ public:
void semantic2(Scope *sc);
void semantic3(Scope *sc);
Dsymbol *toAlias(); // resolve real symbol
- const char *kind();
+ const char *kind() const;
bool oneMember(Dsymbol **ps, Identifier *ident);
const char *toChars();
const char* toPrettyCharsHelper();
@@ -371,7 +371,7 @@ public:
void semantic(Scope *sc);
void semantic2(Scope *sc);
void semantic3(Scope *sc);
- const char *kind();
+ const char *kind() const;
bool oneMember(Dsymbol **ps, Identifier *ident);
int apply(Dsymbol_apply_ft_t fp, void *param);
bool hasPointers();
diff --git a/gcc/d/dmd/tokens.c b/gcc/d/dmd/tokens.c
index 6f68e47..7251c26 100644
--- a/gcc/d/dmd/tokens.c
+++ b/gcc/d/dmd/tokens.c
@@ -8,8 +8,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/lexer.c
*/
-#include <stdio.h>
-#include <ctype.h>
+#include "root/dsystem.h"
#include "tokens.h"
#include "root/rmem.h"
diff --git a/gcc/d/dmd/traits.c b/gcc/d/dmd/traits.c
index b869893..e4ebea6 100644
--- a/gcc/d/dmd/traits.c
+++ b/gcc/d/dmd/traits.c
@@ -8,16 +8,11 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/traits.c
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <assert.h>
-#include <math.h>
-
+#include "root/dsystem.h"
#include "root/rmem.h"
#include "root/aav.h"
+#include "root/checkedint.h"
-#include "checkedint.h"
#include "errors.h"
#include "mtype.h"
#include "init.h"
diff --git a/gcc/d/dmd/unittests.c b/gcc/d/dmd/unittests.c
deleted file mode 100644
index 4827822..0000000
--- a/gcc/d/dmd/unittests.c
+++ /dev/null
@@ -1,26 +0,0 @@
-
-/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2018 by The D Language Foundation, All Rights Reserved
- * written by Walter Bright
- * http://www.digitalmars.com
- * Distributed under the Boost Software License, Version 1.0.
- * http://www.boost.org/LICENSE_1_0.txt
- * https://github.com/D-Programming-Language/dmd/blob/master/src/unittests.c
- */
-
-#include <stdio.h>
-
-#include "mars.h"
-
-void unittest_speller();
-void unittest_importHint();
-void unittest_aa();
-
-void unittests()
-{
-#if UNITTEST
- unittest_speller();
- unittest_importHint();
- unittest_aa();
-#endif
-}
diff --git a/gcc/d/dmd/utf.c b/gcc/d/dmd/utf.c
index f07340e..6eb4699 100644
--- a/gcc/d/dmd/utf.c
+++ b/gcc/d/dmd/utf.c
@@ -17,8 +17,6 @@
/// [3] http://unicode.org/faq/utf_bom.html
/// [4] http://www.unicode.org/versions/Unicode6.1.0/ch03.pdf
-#include <assert.h>
-
#include "utf.h"
/* The following encodings are valid, except for the 5 and 6 byte
diff --git a/gcc/d/dmd/utf.h b/gcc/d/dmd/utf.h
index 154d39a..831128e 100644
--- a/gcc/d/dmd/utf.h
+++ b/gcc/d/dmd/utf.h
@@ -10,7 +10,7 @@
#pragma once
-#include <stdlib.h>
+#include "root/dsystem.h"
/// A UTF-8 code unit
typedef unsigned char utf8_t;
diff --git a/gcc/d/dmd/utils.c b/gcc/d/dmd/utils.c
index e3ea8c1..177f3cf 100644
--- a/gcc/d/dmd/utils.c
+++ b/gcc/d/dmd/utils.c
@@ -7,12 +7,13 @@
* http://www.boost.org/LICENSE_1_0.txt
*/
-#include <string.h>
+#include "root/dsystem.h"
#include "mars.h"
#include "globals.h"
#include "root/file.h"
#include "root/filename.h"
#include "root/outbuffer.h"
+#include "root/rmem.h"
/**
* Normalize path by turning forward slashes into backslashes
@@ -28,7 +29,7 @@ const char * toWinPath(const char *src)
if (src == NULL)
return NULL;
- char *result = strdup(src);
+ char *result = mem.xstrdup(src);
char *p = result;
while (*p != '\0')
{
diff --git a/gcc/d/dmd/version.h b/gcc/d/dmd/version.h
index 6268822..cdff1a8 100644
--- a/gcc/d/dmd/version.h
+++ b/gcc/d/dmd/version.h
@@ -24,7 +24,7 @@ public:
const char *toChars();
void addMember(Scope *sc, ScopeDsymbol *sds);
void semantic(Scope *sc);
- const char *kind();
+ const char *kind() const;
void accept(Visitor *v) { v->visit(this); }
};
@@ -40,6 +40,6 @@ public:
const char *toChars();
void addMember(Scope *sc, ScopeDsymbol *sds);
void semantic(Scope *sc);
- const char *kind();
+ const char *kind() const;
void accept(Visitor *v) { v->visit(this); }
};
diff --git a/gcc/d/dmd/visitor.h b/gcc/d/dmd/visitor.h
index ee0db98..b86f4f6 100644
--- a/gcc/d/dmd/visitor.h
+++ b/gcc/d/dmd/visitor.h
@@ -9,7 +9,7 @@
#pragma once
-#include <assert.h>
+#include "root/dsystem.h"
class Statement;
class ErrorStatement;