d: Merge upstream dmd 740f3d1ea.
authorIain Buclaw <ibuclaw@gdcproject.org>
Fri, 5 Jun 2020 21:09:23 +0000 (23:09 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Fri, 5 Jun 2020 21:14:21 +0000 (23:14 +0200)
Backports the conversion of the parameter fields debugids and versionids
to Identifiers.  The idea is that Identifiers should be used instead of
C strings where ever possible.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 740f3d1ea.
* d-lang.cc (d_handle_option): Use new fields to save debug and
version levels passed over command-line.
(d_post_options): Add them to front-end here.

gcc/d/d-lang.cc
gcc/d/dmd/MERGE
gcc/d/dmd/cond.c
gcc/d/dmd/cond.h
gcc/d/dmd/dversion.c
gcc/d/dmd/globals.h
gcc/d/dmd/module.h

index 203039e..54d5799 100644 (file)
@@ -443,14 +443,16 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
          int level = integral_argument (arg);
          if (level != -1)
            {
-             DebugCondition::setGlobalLevel (level);
+             global.params.debuglevel = level;
              break;
            }
        }
 
       if (Identifier::isValidIdentifier (CONST_CAST (char *, arg)))
        {
-         DebugCondition::addGlobalIdent (arg);
+         if (!global.params.debugids)
+           global.params.debugids = new Strings ();
+         global.params.debugids->push (arg);
          break;
        }
 
@@ -582,14 +584,16 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
          int level = integral_argument (arg);
          if (level != -1)
            {
-             VersionCondition::setGlobalLevel (level);
+             global.params.versionlevel = level;
              break;
            }
        }
 
       if (Identifier::isValidIdentifier (CONST_CAST (char *, arg)))
        {
-         VersionCondition::addGlobalIdent (arg);
+         if (!global.params.versionids)
+           global.params.versionids = new Strings ();
+         global.params.versionids->push (arg);
          break;
        }
 
@@ -812,6 +816,25 @@ d_post_options (const char ** fn)
   /* Has no effect yet.  */
   global.params.pic = flag_pic != 0;
 
+  /* Add in versions given on the command line.  */
+  if (global.params.versionids)
+    {
+      for (size_t i = 0; i < global.params.versionids->length; i++)
+       {
+         const char *s = (*global.params.versionids)[i];
+         VersionCondition::addGlobalIdent (s);
+       }
+    }
+
+  if (global.params.debugids)
+    {
+      for (size_t i = 0; i < global.params.debugids->length; i++)
+       {
+         const char *s = (*global.params.debugids)[i];
+         DebugCondition::addGlobalIdent (s);
+       }
+    }
+
   if (warn_return_type == -1)
     warn_return_type = 0;
 
index 3248bf7..540801d 100644 (file)
@@ -1,4 +1,4 @@
-f5638c7b8a6912858a9b51987df6a725e6796dc9
+740f3d1eab81d88d11451083d955d5075f60d4e0
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
index 88febdf..53c5499 100644 (file)
 Expression *semantic(Expression *e, Scope *sc);
 bool evalStaticCondition(Scope *sc, Expression *exp, Expression *e, bool &errors);
 
-int findCondition(Strings *ids, Identifier *ident)
+int findCondition(Identifiers *ids, Identifier *ident)
 {
     if (ids)
     {
         for (size_t i = 0; i < ids->length; i++)
         {
-            const char *id = (*ids)[i];
+            Identifier *id = (*ids)[i];
 
-            if (strcmp(id, ident->toChars()) == 0)
+            if (id == ident)
                 return true;
         }
     }
@@ -391,16 +391,11 @@ Condition *DVCondition::syntaxCopy()
 
 /* ============================================================ */
 
-void DebugCondition::setGlobalLevel(unsigned level)
-{
-    global.params.debuglevel = level;
-}
-
 void DebugCondition::addGlobalIdent(const char *ident)
 {
-    if (!global.params.debugids)
-        global.params.debugids = new Strings();
-    global.params.debugids->push(ident);
+    if (!global.debugids)
+        global.debugids = new Identifiers();
+    global.debugids->push(Identifier::idPool(ident));
 }
 
 
@@ -444,12 +439,12 @@ int DebugCondition::include(Scope *sc)
                 inc = 1;
                 definedInModule = true;
             }
-            else if (findCondition(global.params.debugids, ident))
+            else if (findCondition(global.debugids, ident))
                 inc = 1;
             else
             {   if (!mod->debugidsNot)
-                    mod->debugidsNot = new Strings();
-                mod->debugidsNot->push(ident->toChars());
+                    mod->debugidsNot = new Identifiers();
+                mod->debugidsNot->push(ident);
             }
         }
         else if (level <= global.params.debuglevel || level <= mod->debuglevel)
@@ -462,11 +457,6 @@ int DebugCondition::include(Scope *sc)
 
 /* ============================================================ */
 
-void VersionCondition::setGlobalLevel(unsigned level)
-{
-    global.params.versionlevel = level;
-}
-
 static bool isReserved(const char *ident)
 {
     static const char* reserved[] =
@@ -598,9 +588,9 @@ void VersionCondition::addGlobalIdent(const char *ident)
 
 void VersionCondition::addPredefinedGlobalIdent(const char *ident)
 {
-    if (!global.params.versionids)
-        global.params.versionids = new Strings();
-    global.params.versionids->push(ident);
+    if (!global.versionids)
+        global.versionids = new Identifiers();
+    global.versionids->push(Identifier::idPool(ident));
 }
 
 
@@ -624,13 +614,13 @@ int VersionCondition::include(Scope *sc)
                 inc = 1;
                 definedInModule = true;
             }
-            else if (findCondition(global.params.versionids, ident))
+            else if (findCondition(global.versionids, ident))
                 inc = 1;
             else
             {
                 if (!mod->versionidsNot)
-                    mod->versionidsNot = new Strings();
-                mod->versionidsNot->push(ident->toChars());
+                    mod->versionidsNot = new Identifiers();
+                mod->versionidsNot->push(ident);
             }
         }
         else if (level <= global.params.versionlevel || level <= mod->versionlevel)
index c32f7bb..1963f05 100644 (file)
@@ -23,7 +23,7 @@ class DebugCondition;
 class ForeachStatement;
 class ForeachRangeStatement;
 
-int findCondition(Strings *ids, Identifier *ident);
+int findCondition(Identifiers *ids, Identifier *ident);
 
 class Condition
 {
@@ -76,7 +76,6 @@ public:
 class DebugCondition : public DVCondition
 {
 public:
-    static void setGlobalLevel(unsigned level);
     static void addGlobalIdent(const char *ident);
 
     DebugCondition(Module *mod, unsigned level, Identifier *ident);
@@ -89,7 +88,6 @@ public:
 class VersionCondition : public DVCondition
 {
 public:
-    static void setGlobalLevel(unsigned level);
     static void addGlobalIdent(const char *ident);
     static void addPredefinedGlobalIdent(const char *ident);
 
index f9f4b75..3c539a7 100644 (file)
@@ -81,8 +81,8 @@ void DebugSymbol::addMember(Scope *, ScopeDsymbol *sds)
                 errors = true;
             }
             if (!m->debugids)
-                m->debugids = new Strings();
-            m->debugids->push(ident->toChars());
+                m->debugids = new Identifiers();
+            m->debugids->push(ident);
         }
     }
     else
@@ -172,8 +172,8 @@ void VersionSymbol::addMember(Scope *, ScopeDsymbol *sds)
                 errors = true;
             }
             if (!m->versionids)
-                m->versionids = new Strings();
-            m->versionids->push(ident->toChars());
+                m->versionids = new Identifiers();
+            m->versionids->push(ident);
         }
     }
     else
index be75fc0..a6449b9 100644 (file)
@@ -239,6 +239,9 @@ struct Global
 
     void* console;         // opaque pointer to console for controlling text attributes
 
+    Array<class Identifier*>* versionids; // command line versions and predefined versions
+    Array<class Identifier*>* debugids;   // command line debug versions and predefined versions
+
     /* Start gagging. Return the current number of gagged errors
      */
     unsigned startGagging();
index 5c799bb..17ad590 100644 (file)
@@ -100,12 +100,12 @@ public:
     Modules aimports;             // all imported modules
 
     unsigned debuglevel;        // debug level
-    Strings *debugids;      // debug identifiers
-    Strings *debugidsNot;       // forward referenced debug identifiers
+    Identifiers *debugids;      // debug identifiers
+    Identifiers *debugidsNot;       // forward referenced debug identifiers
 
     unsigned versionlevel;      // version level
-    Strings *versionids;    // version identifiers
-    Strings *versionidsNot;     // forward referenced version identifiers
+    Identifiers *versionids;    // version identifiers
+    Identifiers *versionidsNot;     // forward referenced version identifiers
 
     Macro *macrotable;          // document comment macros
     Escape *escapetable;        // document comment escapes