aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2020-06-07 11:26:32 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2020-06-07 14:16:33 +0200
commitd8930b138788258aaad77b8fe821ce44d08a66d1 (patch)
tree1093e7665bae9d6d13ece511fec69cbc16d14646 /gcc
parent557a40f599f64e40cc1b20254bf82acc775375f5 (diff)
downloadgcc-d8930b138788258aaad77b8fe821ce44d08a66d1.zip
gcc-d8930b138788258aaad77b8fe821ce44d08a66d1.tar.gz
gcc-d8930b138788258aaad77b8fe821ce44d08a66d1.tar.bz2
d: Merge upstream dmd cef1e7991.
Adds a DString type, a struct that has a compatible layout with D strings. Many parameters in the Global struct have been switched over to this type, and users of these params have been adjust to use the length or ptr field as appropriate. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd cef1e7991. * d-lang.cc (d_parse_file): Adjust for new field types.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/d/d-lang.cc9
-rw-r--r--gcc/d/dmd/MERGE2
-rw-r--r--gcc/d/dmd/attrib.c2
-rw-r--r--gcc/d/dmd/cond.c2
-rw-r--r--gcc/d/dmd/dimport.c2
-rw-r--r--gcc/d/dmd/dmodule.c18
-rw-r--r--gcc/d/dmd/expressionsem.c4
-rw-r--r--gcc/d/dmd/globals.h63
-rw-r--r--gcc/d/dmd/lexer.c4
-rw-r--r--gcc/d/dmd/root/dcompat.h16
10 files changed, 70 insertions, 52 deletions
diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index 54d5799..c4477cd 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -1027,8 +1027,8 @@ d_parse_file (void)
{
if (global.params.verbose)
{
- message ("binary %s", global.params.argv0);
- message ("version %s", global.version);
+ message ("binary %s", global.params.argv0.ptr);
+ message ("version %s", global.version.ptr);
if (global.params.versionids)
{
@@ -1300,11 +1300,12 @@ d_parse_file (void)
OutBuffer buf;
json_generate (&buf, &modules);
- const char *name = global.params.jsonfilename;
+ const char *name = global.params.jsonfilename.ptr;
if (name && (name[0] != '-' || name[1] != '\0'))
{
- const char *nameext = FileName::defaultExt (name, global.json_ext);
+ const char *nameext
+ = FileName::defaultExt (name, global.json_ext.ptr);
File *fjson = File::create (nameext);
fjson->setbuffer ((void *) buf.data, buf.offset);
fjson->ref = 1;
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 540801d..fa94d63 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-740f3d1eab81d88d11451083d955d5075f60d4e0
+cef1e7991121a22f50e9966ea407805015922bc7
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/attrib.c b/gcc/d/dmd/attrib.c
index 184af1f..f4ca06d 100644
--- a/gcc/d/dmd/attrib.c
+++ b/gcc/d/dmd/attrib.c
@@ -994,7 +994,7 @@ void PragmaDeclaration::semantic(Scope *sc)
name[se->len] = 0;
if (global.params.verbose)
message("library %s", name);
- if (global.params.moduleDeps && !global.params.moduleDepsFile)
+ if (global.params.moduleDeps && !global.params.moduleDepsFile.length)
{
OutBuffer *ob = global.params.moduleDeps;
Module *imod = sc->instantiatingModule();
diff --git a/gcc/d/dmd/cond.c b/gcc/d/dmd/cond.c
index 53c5499..63f294a 100644
--- a/gcc/d/dmd/cond.c
+++ b/gcc/d/dmd/cond.c
@@ -407,7 +407,7 @@ DebugCondition::DebugCondition(Module *mod, unsigned level, Identifier *ident)
// Helper for printing dependency information
void printDepsConditional(Scope *sc, DVCondition* condition, const char* depType)
{
- if (!global.params.moduleDeps || global.params.moduleDepsFile)
+ if (!global.params.moduleDeps || global.params.moduleDepsFile.length)
return;
OutBuffer *ob = global.params.moduleDeps;
Module* imod = sc ? sc->instantiatingModule() : condition->mod;
diff --git a/gcc/d/dmd/dimport.c b/gcc/d/dmd/dimport.c
index b176d8c..32602d2 100644
--- a/gcc/d/dmd/dimport.c
+++ b/gcc/d/dmd/dimport.c
@@ -321,7 +321,7 @@ void Import::semantic(Scope *sc)
OutBuffer *ob = global.params.moduleDeps;
Module* imod = sc->instantiatingModule();
- if (!global.params.moduleDepsFile)
+ if (!global.params.moduleDepsFile.length)
ob->writestring("depsImport ");
ob->writestring(imod->toPrettyChars());
ob->writestring(" (");
diff --git a/gcc/d/dmd/dmodule.c b/gcc/d/dmd/dmodule.c
index ba7885e..09e9547 100644
--- a/gcc/d/dmd/dmodule.c
+++ b/gcc/d/dmd/dmodule.c
@@ -91,7 +91,7 @@ Module::Module(const char *filename, Identifier *ident, int doDocComment, int do
nameoffset = 0;
namelen = 0;
- srcfilename = FileName::defaultExt(filename, global.mars_ext);
+ srcfilename = FileName::defaultExt(filename, global.mars_ext.ptr);
if (global.run_noext && global.params.run &&
!FileName::ext(filename) &&
@@ -101,8 +101,8 @@ Module::Module(const char *filename, Identifier *ident, int doDocComment, int do
FileName::free(srcfilename);
srcfilename = FileName::removeExt(filename); // just does a mem.strdup(filename)
}
- else if (!FileName::equalsExt(srcfilename, global.mars_ext) &&
- !FileName::equalsExt(srcfilename, global.hdr_ext) &&
+ else if (!FileName::equalsExt(srcfilename, global.mars_ext.ptr) &&
+ !FileName::equalsExt(srcfilename, global.hdr_ext.ptr) &&
!FileName::equalsExt(srcfilename, "dd"))
{
error("source file name '%s' must have .%s extension", srcfilename, global.mars_ext);
@@ -112,13 +112,13 @@ Module::Module(const char *filename, Identifier *ident, int doDocComment, int do
if (!FileName::absolute(srcfilename))
srcfilePath = getcwd(NULL, 0);
- objfile = setOutfile(global.params.objname, global.params.objdir, filename, global.obj_ext);
+ objfile = setOutfile(global.params.objname.ptr, global.params.objdir.ptr, filename, global.obj_ext.ptr);
if (doDocComment)
setDocfile();
if (doHdrGen)
- hdrfile = setOutfile(global.params.hdrname, global.params.hdrdir, arg, global.hdr_ext);
+ hdrfile = setOutfile(global.params.hdrname.ptr, global.params.hdrdir.ptr, arg, global.hdr_ext.ptr);
//objfile = new File(objfilename);
}
@@ -130,7 +130,7 @@ Module *Module::create(const char *filename, Identifier *ident, int doDocComment
void Module::setDocfile()
{
- docfile = setOutfile(global.params.docname, global.params.docdir, arg, global.doc_ext);
+ docfile = setOutfile(global.params.docname.ptr, global.params.docdir.ptr, arg, global.doc_ext.ptr);
}
/*********************************************
@@ -302,7 +302,7 @@ 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.");
- const char *dmdConfFile = global.inifilename ? FileName::canonicalName(global.inifilename) : NULL;
+ const char *dmdConfFile = global.inifilename.length ? FileName::canonicalName(global.inifilename.ptr) : NULL;
errorSupplemental(loc, "config file: %s", dmdConfFile ? dmdConfFile : "not found");
}
else
@@ -1288,11 +1288,11 @@ const char *lookForSourceFile(const char **path, const char *filename)
*/
*path = NULL;
- const char *sdi = FileName::forceExt(filename, global.hdr_ext);
+ const char *sdi = FileName::forceExt(filename, global.hdr_ext.ptr);
if (FileName::exists(sdi) == 1)
return sdi;
- const char *sd = FileName::forceExt(filename, global.mars_ext);
+ const char *sd = FileName::forceExt(filename, global.mars_ext.ptr);
if (FileName::exists(sd) == 1)
return sd;
diff --git a/gcc/d/dmd/expressionsem.c b/gcc/d/dmd/expressionsem.c
index 75e4d13..4db9591 100644
--- a/gcc/d/dmd/expressionsem.c
+++ b/gcc/d/dmd/expressionsem.c
@@ -2373,13 +2373,13 @@ public:
OutBuffer *ob = global.params.moduleDeps;
Module* imod = sc->instantiatingModule();
- if (!global.params.moduleDepsFile)
+ if (!global.params.moduleDepsFile.length)
ob->writestring("depsFile ");
ob->writestring(imod->toPrettyChars());
ob->writestring(" (");
escapePath(ob, imod->srcfile->toChars());
ob->writestring(") : ");
- if (global.params.moduleDepsFile)
+ if (global.params.moduleDepsFile.length)
ob->writestring("string : ");
ob->writestring((char *) se->string);
ob->writestring(" (");
diff --git a/gcc/d/dmd/globals.h b/gcc/d/dmd/globals.h
index a6449b9..5b5aac3 100644
--- a/gcc/d/dmd/globals.h
+++ b/gcc/d/dmd/globals.h
@@ -144,26 +144,26 @@ struct Param
CHECKACTION checkAction; // action to take when bounds, asserts or switch defaults are violated
- const char *argv0; // program name
+ DString argv0; // program name
Array<const char *> *modFileAliasStrings; // array of char*'s of -I module filename alias strings
Array<const char *> *imppath; // array of char*'s of where to look for import modules
Array<const char *> *fileImppath; // array of char*'s of where to look for file import modules
- const char *objdir; // .obj/.lib file output directory
- const char *objname; // .obj file output name
- const char *libname; // .lib file output name
+ DString objdir; // .obj/.lib file output directory
+ DString objname; // .obj file output name
+ DString libname; // .lib file output name
bool doDocComments; // process embedded documentation comments
- const char *docdir; // write documentation file to docdir directory
- const char *docname; // write documentation file to docname
+ DString docdir; // write documentation file to docdir directory
+ DString docname; // write documentation file to docname
Array<const char *> *ddocfiles; // macro include files for Ddoc
bool doHdrGeneration; // process embedded documentation comments
- const char *hdrdir; // write 'header' file to docdir directory
- const char *hdrname; // write 'header' file to docname
+ DString hdrdir; // write 'header' file to docdir directory
+ DString hdrname; // write 'header' file to docname
bool hdrStripPlainFunctions; // strip the bodies of plain (non-template) functions
bool doJsonGeneration; // write JSON file
- const char *jsonfilename; // write JSON file to jsonfilename
+ DString jsonfilename; // write JSON file to jsonfilename
unsigned debuglevel; // debug level
Array<const char *> *debugids; // debug identifiers
@@ -171,11 +171,11 @@ struct Param
unsigned versionlevel; // version level
Array<const char *> *versionids; // version identifiers
- const char *defaultlibname; // default library for non-debug builds
- const char *debuglibname; // default library for debug builds
- const char *mscrtlib; // MS C runtime library
+ DString defaultlibname; // default library for non-debug builds
+ DString debuglibname; // default library for debug builds
+ DString mscrtlib; // MS C runtime library
- const char *moduleDepsFile; // filename for deps output
+ DString moduleDepsFile; // filename for deps output
OutBuffer *moduleDeps; // contents to be written to deps file
// Hidden debug switches
@@ -194,10 +194,10 @@ struct Param
Array<const char *> *linkswitches;
Array<const char *> *libfiles;
Array<const char *> *dllfiles;
- const char *deffile;
- const char *resfile;
- const char *exefile;
- const char *mapfile;
+ DString deffile;
+ DString resfile;
+ DString exefile;
+ DString mapfile;
};
typedef unsigned structalign_t;
@@ -207,26 +207,27 @@ typedef unsigned structalign_t;
struct Global
{
- const char *inifilename;
- const char *mars_ext;
- const char *obj_ext;
- const char *lib_ext;
- const char *dll_ext;
- const char *doc_ext; // for Ddoc generated files
- const char *ddoc_ext; // for Ddoc macro include files
- const char *hdr_ext; // for D 'header' import files
- const char *json_ext; // for JSON files
- const char *map_ext; // for .map files
+ DString inifilename;
+ DString mars_ext;
+ DString obj_ext;
+ DString lib_ext;
+ DString dll_ext;
+ DString doc_ext; // for Ddoc generated files
+ DString ddoc_ext; // for Ddoc macro include files
+ DString hdr_ext; // for D 'header' import files
+ DString cxxhdr_ext; // for C/C++ 'header' files
+ DString json_ext; // for JSON files
+ DString map_ext; // for .map files
bool run_noext; // allow -run sources without extensions.
- const char *copyright;
- const char *written;
+ DString copyright;
+ DString written;
const char *main_d; // dummy filename for dummy main()
Array<const char *> *path; // Array of char*'s which form the import lookup path
Array<const char *> *filePath; // Array of char*'s which form the file import lookup path
- const char *version; // Compiler version string
- const char *vendor; // Compiler backend name
+ DString version; // Compiler version string
+ DString vendor; // Compiler backend name
Param params;
unsigned errors; // number of errors reported so far
diff --git a/gcc/d/dmd/lexer.c b/gcc/d/dmd/lexer.c
index 421d02a..777842b 100644
--- a/gcc/d/dmd/lexer.c
+++ b/gcc/d/dmd/lexer.c
@@ -401,7 +401,7 @@ void Lexer::scan(Token *t)
}
else if (id == Id::VENDOR)
{
- t->ustring = (utf8_t *)const_cast<char *>(global.vendor);
+ t->ustring = (utf8_t *)const_cast<char *>(global.vendor.ptr);
goto Lstr;
}
else if (id == Id::TIMESTAMP)
@@ -417,7 +417,7 @@ void Lexer::scan(Token *t)
unsigned minor = 0;
bool point = false;
- for (const char *p = global.version + 1; 1; p++)
+ for (const char *p = global.version.ptr + 1; 1; p++)
{
c = *p;
if (isdigit((utf8_t)c))
diff --git a/gcc/d/dmd/root/dcompat.h b/gcc/d/dmd/root/dcompat.h
index dc9a788..72326d5 100644
--- a/gcc/d/dmd/root/dcompat.h
+++ b/gcc/d/dmd/root/dcompat.h
@@ -17,6 +17,22 @@ struct DArray
{
size_t length;
T *ptr;
+
+ DArray() : length(0), ptr(NULL) { }
+
+ DArray(size_t length_in, T *ptr_in)
+ : length(length_in), ptr(ptr_in) { }
+};
+
+struct DString : public DArray<const char>
+{
+ DString() : DArray<const char>() { }
+
+ DString(const char *ptr)
+ : DArray<const char>(ptr ? strlen(ptr) : 0, ptr) { }
+
+ DString(size_t length, const char *ptr)
+ : DArray<const char>(length, ptr) { }
};
/// Corresponding C++ type that maps to D size_t