]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Merge upstream dmd cef1e7991.
authorIain Buclaw <ibuclaw@gdcproject.org>
Sun, 7 Jun 2020 09:26:32 +0000 (11:26 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Sun, 7 Jun 2020 12:16:33 +0000 (14:16 +0200)
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.

gcc/d/d-lang.cc
gcc/d/dmd/MERGE
gcc/d/dmd/attrib.c
gcc/d/dmd/cond.c
gcc/d/dmd/dimport.c
gcc/d/dmd/dmodule.c
gcc/d/dmd/expressionsem.c
gcc/d/dmd/globals.h
gcc/d/dmd/lexer.c
gcc/d/dmd/root/dcompat.h

index 54d5799e59ca7bfd5225b7b83becdd3fc28ab55a..c4477cd90cb1cbfeceeef737f78262fe5dc3225c 100644 (file)
@@ -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;
index 540801d1d4437f5f6ac72ed105192d3427e3b424..fa94d63e4710357fbbae407d5cca3072a3a529e1 100644 (file)
@@ -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.
index 184af1f288c2b2b5a37f0e60bcac60f9da85dc7e..f4ca06d296a9942f3c2462378da6d5b552687fa3 100644 (file)
@@ -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();
index 53c5499f158c888b42054198a9ab3a60034f3907..63f294a587c6f6c9da556e908eae5f810a44e16e 100644 (file)
@@ -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;
index b176d8cadd05ec48ef85294609217c8c1e87561d..32602d27e6ca3022d5158597c360e06879d29f11 100644 (file)
@@ -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(" (");
index ba7885e8c760dba90dd3b8960fa65be91aca118d..09e95472330ef3488d803e340f2bb5ff5ffceef5 100644 (file)
@@ -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;
 
index 75e4d130564ac84d86774726bfa4f040cdd5f666..4db9591a597aea193bc7929be7f3ba5acf32d466 100644 (file)
@@ -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(" (");
index a6449b93ab828c2cbfa2fd4fc4954f8d28ae533b..5b5aac3ab68d79a1024ce84c4948fd284c659821 100644 (file)
@@ -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
index 421d02a5da77bab0af77fdeb868eb3ea1e2addfc..777842beff4d556222178b01a878c1b16aaae1be 100644 (file)
@@ -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))
index dc9a7883927af7c1d694071d280191047f05957b..72326d5ff6560586413bfdcb04062826ec8a8a79 100644 (file)
@@ -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