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
This commit is contained in:
Iain Buclaw 2018-11-04 23:34:44 +00:00 committed by Iain Buclaw
parent e8bf3d5ed9
commit f9ab59ffe7
104 changed files with 360 additions and 483 deletions

View 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

53
gcc/d/d-system.h Normal file
View File

@ -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 */

4
gcc/d/dmd/MERGE Normal file
View File

@ -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.

View 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"

View 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;

View 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";
}

View 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); }
};

View 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"

View 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"

View 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"

View 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"

View 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);

View 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"

View 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"

View 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.

View 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"

View 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);

View 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)
{

View 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"

View 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"

View 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";
}

View 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";
}

View 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();

View 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"

View 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";
}

View 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";
}

View 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"

View File

@ -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"

View 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"

View 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"
@ -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";
}

View File

@ -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"

View File

@ -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);

View 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"

View 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";
}

View 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";
}

View 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; }
};

View 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";
}

View 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";
}

View 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"
/*********************************************

View 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);

View File

@ -10,6 +10,7 @@
#pragma once
#include "root/dsystem.h"
#include "globals.h"
bool isConsoleColorSupported();

View 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"

View 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
};
/****************************************************************/

View 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"

View 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";
}

View 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;

View File

@ -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);

View File

@ -10,8 +10,7 @@
#pragma once
#include <string.h> // memset()
#include "root/dsystem.h" // memset()
#include "dsymbol.h"
void genhdrfile(Module *m);

View 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"

View File

@ -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
{

View 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"

View 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"

View 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);

View 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"

View 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"

View 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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View 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

View 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.

View 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;
}

View 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";
}

View 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); }
};

View 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"

View 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"

View File

@ -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"

View 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];

View File

@ -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"

View File

@ -8,6 +8,8 @@
#pragma once
#include "dsystem.h"
typedef void* Value;
typedef void* Key;

View 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"

View File

@ -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.
*

View 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);

View File

@ -9,6 +9,8 @@
#pragma once
#include "dsystem.h"
/// Represents a D [ ] array
template<typename T>
struct DArray

24
gcc/d/dmd/root/dsystem.h Normal file
View File

@ -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"

View 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;

View File

@ -8,8 +8,7 @@
#pragma once
#include <stddef.h>
#include "dsystem.h"
#include "array.h"
typedef Array<struct File *> Files;

View 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

View 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.

View 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
};
/*

View 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"

View 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"

View File

@ -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

View 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");

View 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

View 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"

View 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_";

View 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"

View 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"

View 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"

View 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"

View 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"

View 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";
}

View 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); }
};

View File

@ -19,6 +19,7 @@
class ClassDeclaration;
class Dsymbol;
class Expression;
class Parameter;
class Type;
struct OutBuffer;

View 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();

View 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"

View 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"

View File

@ -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
}

View 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

Some files were not shown because too many files have changed in this diff Show More