]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Merge dmd upstream 6243fa6d2
authorIain Buclaw <ibuclaw@gdcproject.org>
Sun, 4 Nov 2018 23:34:44 +0000 (23:34 +0000)
committerIain Buclaw <ibuclaw@gcc.gnu.org>
Sun, 4 Nov 2018 23:34:44 +0000 (23:34 +0000)
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

104 files changed:
gcc/d/ChangeLog
gcc/d/d-system.h [new file with mode: 0644]
gcc/d/dmd/MERGE [new file with mode: 0644]
gcc/d/dmd/access.c
gcc/d/dmd/aggregate.h
gcc/d/dmd/aliasthis.c
gcc/d/dmd/aliasthis.h
gcc/d/dmd/apply.c
gcc/d/dmd/argtypes.c
gcc/d/dmd/arrayop.c
gcc/d/dmd/attrib.c
gcc/d/dmd/attrib.h
gcc/d/dmd/canthrow.c
gcc/d/dmd/clone.c
gcc/d/dmd/compiler.h
gcc/d/dmd/cond.c
gcc/d/dmd/constfold.c
gcc/d/dmd/cppmangle.c
gcc/d/dmd/ctfeexpr.c
gcc/d/dmd/dcast.c
gcc/d/dmd/dclass.c
gcc/d/dmd/declaration.c
gcc/d/dmd/declaration.h
gcc/d/dmd/delegatize.c
gcc/d/dmd/denum.c
gcc/d/dmd/dimport.c
gcc/d/dmd/dinterpret.c
gcc/d/dmd/dmacro.c
gcc/d/dmd/dmangle.c
gcc/d/dmd/dmodule.c
gcc/d/dmd/doc.c
gcc/d/dmd/doc.h
gcc/d/dmd/dscope.c
gcc/d/dmd/dstruct.c
gcc/d/dmd/dsymbol.c
gcc/d/dmd/dsymbol.h
gcc/d/dmd/dtemplate.c
gcc/d/dmd/dversion.c
gcc/d/dmd/entity.c
gcc/d/dmd/enum.h
gcc/d/dmd/errors.h
gcc/d/dmd/expression.c
gcc/d/dmd/expression.h
gcc/d/dmd/expressionsem.c
gcc/d/dmd/func.c
gcc/d/dmd/globals.h
gcc/d/dmd/hdrgen.c
gcc/d/dmd/hdrgen.h
gcc/d/dmd/identifier.c
gcc/d/dmd/idgen.c
gcc/d/dmd/impcnvgen.c
gcc/d/dmd/imphint.c
gcc/d/dmd/import.h
gcc/d/dmd/init.c
gcc/d/dmd/initsem.c
gcc/d/dmd/intrange.c
gcc/d/dmd/json.c
gcc/d/dmd/lexer.c
gcc/d/dmd/macro.h
gcc/d/dmd/mars.h
gcc/d/dmd/module.h
gcc/d/dmd/mtype.c
gcc/d/dmd/nspace.c
gcc/d/dmd/nspace.h
gcc/d/dmd/opover.c
gcc/d/dmd/optimize.c
gcc/d/dmd/parse.c
gcc/d/dmd/parse.h
gcc/d/dmd/root/aav.c
gcc/d/dmd/root/aav.h
gcc/d/dmd/root/array.h
gcc/d/dmd/root/checkedint.c [moved from gcc/d/dmd/checkedint.c with 99% similarity]
gcc/d/dmd/root/checkedint.h [moved from gcc/d/dmd/checkedint.h with 90% similarity]
gcc/d/dmd/root/dcompat.h
gcc/d/dmd/root/dsystem.h [new file with mode: 0644]
gcc/d/dmd/root/file.c
gcc/d/dmd/root/file.h
gcc/d/dmd/root/filename.c
gcc/d/dmd/root/hash.h
gcc/d/dmd/root/object.h
gcc/d/dmd/root/outbuffer.c
gcc/d/dmd/root/outbuffer.h
gcc/d/dmd/root/port.h
gcc/d/dmd/root/rmem.c
gcc/d/dmd/root/rmem.h
gcc/d/dmd/root/rootobject.c
gcc/d/dmd/root/speller.c
gcc/d/dmd/root/stringtable.c
gcc/d/dmd/sapply.c
gcc/d/dmd/sideeffect.c
gcc/d/dmd/statement.c
gcc/d/dmd/statementsem.c
gcc/d/dmd/staticassert.c
gcc/d/dmd/staticassert.h
gcc/d/dmd/target.h
gcc/d/dmd/template.h
gcc/d/dmd/tokens.c
gcc/d/dmd/traits.c
gcc/d/dmd/unittests.c [deleted file]
gcc/d/dmd/utf.c
gcc/d/dmd/utf.h
gcc/d/dmd/utils.c
gcc/d/dmd/version.h
gcc/d/dmd/visitor.h

index 117dbc06c6874fb300b6ee0a6eab5659c434c453..d534f36bb3f8568431105a4dd0bdff6c32a0b580 100644 (file)
@@ -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 (file)
index 0000000..25a83b6
--- /dev/null
@@ -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 (file)
index 0000000..7727205
--- /dev/null
@@ -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.
index 37e9c8681d30a0fca3623f34d73215b9a85fcb9d..cd60cedc2a5a45b4299cc2c7315fef1cb2bb617d 100644 (file)
@@ -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"
 
index d7db82b0f0e87ebd957effa0ccb7243e3bcebf1e..cac0b8efd9f39577dd554c0fd644c178da7bba55 100644 (file)
@@ -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;
index 50921ecb300890ea113b034c9f9e02b5b6a10c06..f4d627ff42d7c039079896d409b0ad45d9ec76fd 100644 (file)
@@ -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";
 }
index e5b0280d9e11571ea74c7a6e10b1f65b704345fc..290ccd63088ca2ea7f83220288411453934af2f7 100644 (file)
@@ -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); }
 };
index f20e411228f4e7b0cdeb65e06dc4c350b531faef..bec32a892e2ffccf0eed312a4601c2fa9b3c6e4f 100644 (file)
@@ -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"
index cad8d4ec92fed29dee5698aa79e1378c5312032d..c37d48a3691314ae32375e7aeba9dc473d7465ed 100644 (file)
@@ -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"
index 0ea0d329399635d464aac1367ea3cc6df28a5d23..91c1b76e4ab4c662f7ce378ee2200d3412799b92 100644 (file)
@@ -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"
 
index c4270ea63e66686611f8a580aaf77a9e762a5b89..05728518ff11d910e000de3931e7e7b8f84e4c2a 100644 (file)
@@ -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"
index 83486a954313ee5aa0bdf7a64fecda7b65c63b51..a491605fc1303ec99e3d9bbc5b77d5a244f02984 100644 (file)
@@ -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);
index a00741b7d72606e59beb6dcab541d6ea8e1caabc..ec15153eb4efd28f479f0516f35a0f74ce409b53 100644 (file)
@@ -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"
index 9105d114eaa01b1449b121884b9fd0c19f4f2bc8..4384dc8064f9d755ac03b9897b257ca97d47fb46 100644 (file)
@@ -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"
index cfcc317ff9c17ee8540c9865ea5d71f24fea187e..6c5cf7bd47489009187666ce7cbb92efb38bb3ca 100644 (file)
@@ -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.
index 047eca261d84b8012fb8c0b5c07d2cb67ed96b6b..0538929f310eca080c3cfa1874cd6007eb967088 100644 (file)
@@ -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"
index 43e831f1dfef3ec4a9a235aae8826cd6a6c1e40e..4b5dceba62ee5e77ca7eba2a338f3ffad84e266e 100644 (file)
@@ -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);
index bb919a5f2bbc1ee956682b26c753553cdd241664..d2d357667cbaafe21c0d511592d068baa5059f81 100644 (file)
@@ -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)
     {
index ad5b827dcd360cddea29233adfff913dfe7e3d13..430342dae54bee3b40904310c5104ede1bdc6559 100644 (file)
@@ -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"
index ee3bfd9d888b47724d2d135fb0977e73354f31e1..39471665e4ab47f00aa5894e70d8298670a99ad2 100644 (file)
@@ -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"
index 414332ccd34a5e25f32bed87cf05671c3efa0468..6fe17b3657670d2b49b895c10fefae500a5d63cb 100644 (file)
@@ -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";
 }
index 76132b9458e05d0b6bc788dfa426aced8967c5f6..9f43b88dd0f7e907fe50688778c67ab5ccc6d1bf 100644 (file)
@@ -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";
 }
index 071ce2ca206a910a1189c3858e5613ae0626a1f8..6952bffb38ac903a908268308d401ff211f52ca3 100644 (file)
@@ -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();
index 99fe93828a62b285b4cc6fbfa4971e82fe658cdb..8745026252eb057aa4579fb1104dec128d337eb7 100644 (file)
@@ -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"
index 4107f11738e6417ee6b609abb9254ea592daf785..56652f219c9b055c270a2916bfd8ce7aa0072fc8 100644 (file)
@@ -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";
 }
index 03b3d1f2c57cfde81d55ab9aab93ff6791f41bb2..922e18a3fe9b63700c0b95330eede7abbb4ff260 100644 (file)
@@ -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";
 }
index 54bf00d5a414b38f9538bb471266f0e679ed6354..2bb1aace2ca155d5fbed2cdb1df1cdabf7844464 100644 (file)
@@ -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"
index a5d8da10c3649217e7f1e42b55428b41500afc5a..c6171229fd9c55f2bde61caecf01a5aec06e60ed 100644 (file)
 /* 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"
index 9734624b2881d5112a81c83cd5f8017dec369139..7686c69c9fe03634147a02c9b11ee96ee08f6383 100644 (file)
@@ -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"
index a374aac73a771227cdedc0daf1d9727d4fb81c3f..55b54b1cee612eb13a7e4542cce49df610d68ad5 100644 (file)
@@ -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"
 #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";
 }
index 92ce33cd546df220d3a401d33a22390c504c5f30..d35ca7b25228f0527db36e1674e24af90be398ae 100644 (file)
 
 // 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"
index 7f3ef5127dea655552685ba49f73f284fbcc27d7..d1428fb8a692a78a2ceb3aa89c8487a802f4a798 100644 (file)
 
 #pragma once
 
+#include "root/dsystem.h"
+
+class Module;
+struct OutBuffer;
+
 void escapeDdocString(OutBuffer *buf, size_t start);
 void gendocfile(Module *m);
index 924a3764c00a432c5f8af459ba626d14cd6f781f..27412b53d1335bd737e911e85401090f6a4f402a 100644 (file)
@@ -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"
index c99abcea9aa146025b82390dcade5bbef59b95e0..f9f15ba9092e7925f61a2d4c44fc9df86c7f2fbe 100644 (file)
@@ -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";
 }
index 0f0a0dc690402019e793ca63fd7c3750d7e3578d..b511b79c7e0cd55ba07e16d1b19bf2764b157424 100644 (file)
@@ -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";
 }
index 0f2f03de4f1c1b46c86499e1f791af3bab41c5c1..421a043c8a226983f73ecfc686ce06154aa10934 100644 (file)
@@ -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; }
 };
index f2b3b2f7b2180c7f48e03729bfb2811d4110872d..9455e976074c5baa012e46b496b140ade6dc9be1 100644 (file)
@@ -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";
 }
index 47374868674dd2b2964fe50ed7b4b4f20454e919..849afaaa6a8de7787cd1dc348f48fe0479962538 100644 (file)
@@ -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";
 }
index 38fd2d8713e4ded12508a41efbf3d502db0b169d..78abc8fad97f2e54867ee8e3c94a7834ddb4778d 100644 (file)
@@ -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"
 
 /*********************************************
index 072eacf583e5ab89fb7a605b042d525ebcd85e3b..ce500579e17382ad3de8553ff92b1493ee85d4a9 100644 (file)
@@ -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);
 
index 7b3ebc0deeb6625562219a27917ac8a027153d6d..42cc1d70eeac03fbe814e9b48ba6b451a8d40858 100644 (file)
@@ -10,6 +10,7 @@
 
 #pragma once
 
+#include "root/dsystem.h"
 #include "globals.h"
 
 bool isConsoleColorSupported();
index dc0d8e7c017269e2ad1c1c98aa653a6406f806b5..359e4cc91fdbbb2a88035410b3cf9a4790d73825 100644 (file)
@@ -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"
 
index 57c516c1d23a4752ef35fb89a2c0042f0ac0c2fe..27a153eaaf1a21108fe24a195ff19b10abd7d73c 100644 (file)
@@ -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
 };
 
 /****************************************************************/
index 247d1433f4b31166048903242386844341248b79..96ae7efd7e363b678850959a5325db30c6c2154d 100644 (file)
@@ -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"
 
index 2feea9126cd48257505ad852cc5a0601b4f46e40..c8f9c5c350a85f7a1535a6c3e9bdcc3aaebab8da 100644 (file)
@@ -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";
 }
index 63caeb7b6b18a7448188fd230775233b2a9fa0ec..e5fefe911ea94a80c913f1eb0b49a60b9116eb3a 100644 (file)
@@ -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;
index 2c734b31822543cf8149bb1b72962f73ade3fa15..a1f3c12ba72819b1547642871e938dc860cd728c 100644 (file)
 
 // 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);
 
index c4bafca6d362e788f9a6e68f7d5e6cdc42a42316..f9178beda8d78a87135ead84efa38e3212cb23ac 100644 (file)
@@ -10,8 +10,7 @@
 
 #pragma once
 
-#include <string.h>                     // memset()
-
+#include "root/dsystem.h"               // memset()
 #include "dsymbol.h"
 
 void genhdrfile(Module *m);
index 5e40746da7db523886d463b576f2ee99e3e54248..f535e5b62a1800422e9af5161ad7c57c8e3b940d 100644 (file)
@@ -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"
index d360ec850d8fdb056d348f3787498e503f907d52..d07725b02539e4bdc831e88cff034e56a0a5f628 100644 (file)
 //      id.h
 //      id.c
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
+#include "root/dsystem.h"
 
 struct Msgtable
 {
index 5b88e8e682e17bf92e1407bd36e753e0544a74d9..15239fdc283bf714c790de0be46bf8469b278142 100644 (file)
@@ -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"
 
index 6d75603d80c72bb2b752a725d3f7e86eb6f3d106..9b29490d361addca76d020f3f1817c2159216373 100644 (file)
@@ -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"
 
index e0fa14d58889a146ef8f7ecde1901c5d8dce7d5b..dcaec5c7acbdbdfb60ae5ae981f680e7e6a4444f 100644 (file)
@@ -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);
index e619cb4850aa5ebd65a15564ab48a4e291f1fa4d..6603f66bfe618156dbf63ae1c11821492051a862 100644 (file)
@@ -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"
index bdaf2534a0c025fc1776968527cc123a89cbeccf..bcb620d820910801b5069133668ad7ab8cd7ab2a 100644 (file)
@@ -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"
index b4d54dbfeea06318d55d2610128d0456fb38720b..966b9a2986e38fa39d0a0a69fdf5e8a20d409014 100644 (file)
@@ -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"
index 4c49023b5429accdc0f3fa0992f2945552a921a6..5ee957103c658c6e9dc019a4867995183ab81340 100644 (file)
 
 // 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"
index 1fefe2b08ded2d87b8c4f9752a56492c43fb7915..0b1824538fd2c1e92637fd2644a9f82fd3f837bb 100644 (file)
 
 /* 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"
index 006f11842c49444b9572a2bf07dda04d75ff25a9..f44108b15175a67fd31bfed8aec95e4dfe262171 100644 (file)
 
 #pragma once
 
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <ctype.h>
-
+#include "root/dsystem.h"
 #include "root/root.h"
 
 
index 9cc5bb86feefce1af9d5eedef490d9c01a42bb85..5aec7e6b45845fe27ad9d1db6430c7aa35b4e8cf 100644 (file)
@@ -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
index 399b0085635668dec62d3d5f6e2b9827ba022820..d8fb020175e9191967817ab6c5bcb781217bd037 100644 (file)
@@ -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.
index a4c38e8a1eef314365a2036d334b53d04d079dec..dedaf7dc83e313f8265461b8a92a6eb917c65559 100644 (file)
@@ -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;
         }
 
index 2bd6b96981352d9e4a4f12e53bd5f9e272975119..49c41f37677edc7a775ae4402548c3b78615fd24 100644 (file)
@@ -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";
 }
index 8ca01ae8485625d67dbb84b2a559d882f5d1d94d..f6c4a3d828833d9f27431a7d438e638e622ac521 100644 (file)
@@ -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); }
 };
index be6fd78886a1e17b007495a53bd221a0972ab36f..0bcccb63afd0ae40f497f5b2fcb9d73d48c2a3ab 100644 (file)
@@ -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"
index 12224fa518840f64d5d2967210c1653ff943d489..89a584bea779d24a4a423caff39ef815f771fb3f 100644 (file)
@@ -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"
index 9ee2f0837b1f47e6e5f3f2b2f0231b40eeed35bb..119876065b150a85191b1de833338057c2b90b3d 100644 (file)
 
 // 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"
index 50381067917fc29b4291df6bd0cee0a24638b0d8..92c09dec07380c4d0625e16ce2ada6bea60ee17e 100644 (file)
@@ -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];
index 4c015bf0700360eea8c2fede172a59d3657ae4fb..931a395a7016f7f17be55b63952aa305186d8a50 100644 (file)
  *
  */
 
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-
+#include "dsystem.h"
 #include "aav.h"
 #include "rmem.h"
 
index 24c281a150364e205a50de33b1b3ccb75398a961..ad57cb4ce4ba76cd2a46a660aa230bb14999e48c 100644 (file)
@@ -8,6 +8,8 @@
 
 #pragma once
 
+#include "dsystem.h"
+
 typedef void* Value;
 typedef void* Key;
 
index ed128b93dd753b2d8053d659e0b18d372e4b9df1..dd2899822901bf8a1ad69f0141f71abc6d40fcb5 100644 (file)
@@ -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"
 
similarity index 99%
rename from gcc/d/dmd/checkedint.c
rename to gcc/d/dmd/root/checkedint.c
index b9ccb5b2397485adc8d98ec6f81bb77947f9b88e..392904acf8a3ddc8b5aa700185e95d07dbba26d9 100644 (file)
  * 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.
  *
similarity index 90%
rename from gcc/d/dmd/checkedint.h
rename to gcc/d/dmd/root/checkedint.h
index 1f6545b6c62ffb9539a70f78203704e434df5647..1362ff51be9fc057bd5d460454f0c46ca5f2612b 100644 (file)
@@ -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);
index 3fc169c034e9a99de52cff9488800584f77fbb2c..f92f0abaabb45b8505602ae1cf7665c018f9cc74 100644 (file)
@@ -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 (file)
index 0000000..940ff50
--- /dev/null
@@ -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"
index f4fd51a0012dacc9252dfd06693970f6641eeb64..454d4cb0760dd36686e7c7b6c1f7527f11274bd4 100644 (file)
@@ -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;
 
index f6953ab34db30a59af765e845899a3d9f8dbd001..f4d2937bfd3e4c0d19e80f2a69c63fe37e1bacba 100644 (file)
@@ -8,8 +8,7 @@
 
 #pragma once
 
-#include <stddef.h>
-
+#include "dsystem.h"
 #include "array.h"
 
 typedef Array<struct File *> Files;
index 307e94f6584f2d4590c373e1be753adf84bd5e59..b0bd1a5a4fdca18fc5972f5d134b092a2f9edfa7 100644 (file)
@@ -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
 
index 1b05672ff9f8f6012f1270cf46ba54da6dd2af92..f1bc6cc5cca02706ab174e07441c9e436b4c935f 100644 (file)
@@ -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.
index e9d770d5d3d3ecabadba1279e05b10007456ffd8..d465e36352288b674304936e9a6072dfb0dbd38e 100644 (file)
@@ -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
 };
 
 /*
index 7b6782defb140b5238c079c11c5f8056fc4f2927..4791bb177c9358660d103224790f8b3b32c33ca3 100644 (file)
@@ -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"
 
index 6d3be1071292095da86c18cc37af0d378f0bd832..6e6b35d8d938f104f4731c355b92cc116de36ef2 100644 (file)
@@ -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"
 
index 3f3c46d9168983419fc838c77936fd8207227172..0dbb3197ad58b684a2334e222cc1f5ddb325fd72 100644 (file)
 // 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
index 92e79ca95ae7380c2c38f45ccfe9204f5a0ebfe7..d24e0126b375e56f0b5195a7ce69660c3a57b6c4 100644 (file)
@@ -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");
index 87d465f1da3d538c2a9cebb1ec171fe87f650910..0123402bfaefb059c41856d08758491e95b9a5a7 100644 (file)
@@ -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
index cd239d6c3ca4532885b44827b0c88000b5601b61..b45e795e14ed5f300f6bb510eb3fb196bc29ea25 100644 (file)
@@ -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"
 
index 52b4e4767f8553d9e54c2a62bc3f97b48ca1d2d9..a5c16bab12d195251d49a74e8d34821d8ab9a4f2 100644 (file)
@@ -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_";
index 158e2af6e236aff44eed4831bc545bad2d50d2c0..473df7cbe50ed0de1f1347b50781f6b11760899b 100644 (file)
@@ -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"
index 89209770234ce192ded9fd7f6982b803bcf90f9c..18689c1f2da4b9c24acadba42a4736c0af4bddd9 100644 (file)
@@ -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"
index 83e797380410433c9b9c4c4edca018a536fb7f0e..56d7d078027ad00240e52213eaab855e540b4d81 100644 (file)
@@ -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"
index 6e679074e0a992e4b8d76a1a56bf4c89c2f2ecd4..561791478baa3d32c87cea3c23452ae63580a5e1 100644 (file)
@@ -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"
index 7ee541c9d50ed9b232cb74b3a34c19853218b947..9be934fb4ef21b696bce70d1f34ae844a43a09d4 100644 (file)
@@ -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"
index 476668f900b142f4ec7e600b9989102067f11f37..5da1f7d9b772061745bc2a68fea7206c105807c3 100644 (file)
@@ -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";
 }
index 0112f0270242d7af4d3fbbe1aab61db5cae58fb0..4a601ab7afac056ba00cf6be757640c55a1e1c7c 100644 (file)
@@ -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); }
 };
index 937900896b290d631f0f442001337ba86925d018..63dfcf261a49cce7faf3be5554d5d6bc3d6cef9b 100644 (file)
@@ -19,6 +19,7 @@
 class ClassDeclaration;
 class Dsymbol;
 class Expression;
+class Parameter;
 class Type;
 struct OutBuffer;
 
index f5991030f399be26cdf7457192115d7f05057118..c913b2a5bfaa1209be15e09a5c38cd7dbb28300b 100644 (file)
@@ -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();
index 6f68e478deecd0fb2fb81574e110a28317f048b1..7251c261cdb025af8cefbcd21ae7dde105429e70 100644 (file)
@@ -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"
index b869893d4f1a208fbc4ebe2f26970a80831864d5..e4ebea683890cbde921d2c8860ebaf78f57b9f22 100644 (file)
@@ -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 (file)
index 4827822..0000000
+++ /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
-}
index f07340e95e00b4627445f8788077865abdab48d3..6eb46993acf47da3552ecfc6c26949c791f9ccb0 100644 (file)
@@ -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
index 154d39ad4743e407bf3f3c8c35a7164bc9e4bff7..831128e7fa7c5cc5c61054ac9f1c33fb9261d31a 100644 (file)
@@ -10,7 +10,7 @@
 
 #pragma once
 
-#include <stdlib.h>
+#include "root/dsystem.h"
 
 /// A UTF-8 code unit
 typedef unsigned char   utf8_t;
index e3ea8c19e50432196ed60cfa77fc001dd6099698..177f3cfa7a631cac161bf48f1ee004f6f34f8f99 100644 (file)
@@ -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')
     {
index 6268822df194ad1476d28705adf01cd6b2a7b20d..cdff1a873fcf34ab0df7fc249e77380aacc0d56c 100644 (file)
@@ -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); }
 };
index ee0db983181dc35954398b39232ff598507114fa..b86f4f675b230167717d99ed04d869939b2cc9bb 100644 (file)
@@ -9,7 +9,7 @@
 
 #pragma once
 
-#include <assert.h>
+#include "root/dsystem.h"
 
 class Statement;
 class ErrorStatement;