]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Merge dmd upstream 5220ad51e
authorIain Buclaw <ibuclaw@gcc.gnu.org>
Sun, 2 Dec 2018 11:47:49 +0000 (11:47 +0000)
committerIain Buclaw <ibuclaw@gcc.gnu.org>
Sun, 2 Dec 2018 11:47:49 +0000 (11:47 +0000)
Backports Ddoc fix that is present in upstream, but did not make its way
into the C++ port of the D front-end implementation.

The old special types for C long, unsigned long, and long double have
also been removed as neither the compiler nor druntime bindings support
handling it anymore.

Commits merged from dmd.

Backport Issue 14633: Fixed false DDoc warnings
https://github.com/dlang/dmd/pull/9027

Remove old support code for struct __c_long/ulong/long_double
https://github.com/dlang/dmd/pull/9028

From-SVN: r266719

gcc/d/dmd/MERGE
gcc/d/dmd/cppmangle.c
gcc/d/dmd/doc.c
gcc/testsuite/gdc.test/compilable/ddoc10236.d
gcc/testsuite/gdc.test/compilable/ddoc10236b.d
gcc/testsuite/gdc.test/compilable/ddoc13502.d
gcc/testsuite/gdc.test/compilable/ddoc4899.d
gcc/testsuite/gdc.test/runnable/cppa.d

index 7727205bed4bcfb7af22b7dfe11065ffe4eed1d5..223ffbdc3582bf3203a7fd81bc62594f87fa7da6 100644 (file)
@@ -1,4 +1,4 @@
-6243fa6d2ceab4615a9fe21c5bc9484e52bb2d1e
+5220ad51eebe06754e6881d9bd5aab89dba2b065
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
index d2d357667cbaafe21c0d511592d068baa5059f81..ad88242d820e632906aa8df87fb5689470f0ad4f 100644 (file)
@@ -952,15 +952,6 @@ public:
         if (t->isImmutable() || t->isShared())
             return error(t);
 
-        /* __c_long and __c_ulong get special mangling
-         */
-        Identifier *id = t->sym->ident;
-        //printf("struct id = '%s'\n", id->toChars());
-        if (id == Id::__c_long)
-            return writeBasicType(t, 0, 'l');
-        else if (id == Id::__c_ulong)
-            return writeBasicType(t, 0, 'm');
-
         //printf("TypeStruct %s\n", t->toChars());
         doSymbol(t);
     }
index d35ca7b25228f0527db36e1674e24af90be398ae..797991ee2c48febd816d959008297be510fde075 100644 (file)
@@ -133,6 +133,25 @@ bool isCVariadicParameter(Dsymbols *a, const utf8_t *p, size_t len)
     return false;
 }
 
+/****************************************************
+ */
+static Parameter *isFunctionParameter(Dsymbol *s, const utf8_t *p, size_t len)
+{
+    TypeFunction *tf = isTypeFunction(s);
+    if (tf && tf->parameters)
+    {
+        for (size_t k = 0; k < tf->parameters->dim; k++)
+        {
+            Parameter *fparam = (*tf->parameters)[k];
+            if (fparam->ident && cmp(fparam->ident->toChars(), p, len) == 0)
+            {
+                return fparam;
+            }
+        }
+    }
+    return NULL;
+}
+
 static Dsymbol *getEponymousMember(TemplateDeclaration *td)
 {
     if (!td->onemember)
@@ -150,6 +169,54 @@ static Dsymbol *getEponymousMember(TemplateDeclaration *td)
     return NULL;
 }
 
+/****************************************************
+ */
+static Parameter *isEponymousFunctionParameter(Dsymbols *a, const utf8_t *p, size_t len)
+{
+    for (size_t i = 0; i < a->dim; i++)
+    {
+        TemplateDeclaration *td = (*a)[i]->isTemplateDeclaration();
+        if (td && td->onemember)
+        {
+            /* Case 1: we refer to a template declaration inside the template
+
+               /// ...ddoc...
+               template case1(T) {
+                 void case1(R)() {}
+               }
+             */
+            td = td->onemember->isTemplateDeclaration();
+        }
+        if (!td)
+        {
+            /* Case 2: we're an alias to a template declaration
+
+               /// ...ddoc...
+               alias case2 = case1!int;
+             */
+            AliasDeclaration *ad = (*a)[i]->isAliasDeclaration();
+            if (ad && ad->aliassym)
+            {
+                td = ad->aliassym->isTemplateDeclaration();
+            }
+        }
+        while (td)
+        {
+            Dsymbol *sym = getEponymousMember(td);
+            if (sym)
+            {
+                Parameter *fparam = isFunctionParameter(sym, p, len);
+                if (fparam)
+                {
+                    return fparam;
+                }
+            }
+            td = td->overnext;
+        }
+    }
+    return NULL;
+}
+
 static TemplateDeclaration *getEponymousParent(Dsymbol *s)
 {
     if (!s->parent)
@@ -1590,6 +1657,12 @@ void ParamSection::write(Loc loc, DocComment *, Scope *sc, Dsymbols *a, OutBuffe
                 {
                     size_t o = buf->offset;
                     Parameter *fparam = isFunctionParameter(a, namestart, namelen);
+                    if (!fparam)
+                    {
+                        // Comments on a template might refer to function parameters within.
+                        // Search the parameters of nested eponymous functions (with the same name.)
+                        fparam = isEponymousFunctionParameter(a, namestart, namelen);
+                    }
                     bool isCVariadic = isCVariadicParameter(a, namestart, namelen);
                     if (isCVariadic)
                     {
@@ -2085,17 +2158,10 @@ Parameter *isFunctionParameter(Dsymbols *a, const utf8_t *p, size_t len)
 {
     for (size_t i = 0; i < a->dim; i++)
     {
-        TypeFunction *tf = isTypeFunction((*a)[i]);
-        if (tf && tf->parameters)
+        Parameter *fparam = isFunctionParameter((*a)[i], p, len);
+        if (fparam)
         {
-            for (size_t k = 0; k < tf->parameters->dim; k++)
-            {
-                Parameter *fparam = (*tf->parameters)[k];
-                if (fparam->ident && cmp(fparam->ident->toChars(), p, len) == 0)
-                {
-                    return fparam;
-                }
-            }
+            return fparam;
         }
     }
     return NULL;
@@ -2108,7 +2174,10 @@ TemplateParameter *isTemplateParameter(Dsymbols *a, const utf8_t *p, size_t len)
 {
     for (size_t i = 0; i < a->dim; i++)
     {
-        TemplateDeclaration *td = getEponymousParent((*a)[i]);
+        TemplateDeclaration *td = (*a)[i]->isTemplateDeclaration();
+        // Check for the parent, if the current symbol is not a template declaration.
+        if (!td)
+            td = getEponymousParent((*a)[i]);
         if (td && td->origParameters)
         {
             for (size_t k = 0; k < td->origParameters->dim; k++)
index 25738ec34e3cfeb6bf54784dfa93260d15d9d926..1c547613c44500ca565cc40bc93aeb3dd3d55e74 100644 (file)
@@ -1,5 +1,5 @@
 // PERMUTE_ARGS:
-// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -w -o-
+// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -wi -o-
 
 /*
 TEST_OUTPUT:
index d814d375c065ef91715aeaf5b23506afcc89085b..065ced0936c0ae91cfa3d0494dfe189ecdd2e5ae 100644 (file)
@@ -1,5 +1,5 @@
 // PERMUTE_ARGS:
-// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -w -o-
+// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -wi -o-
 
 /*
 TEST_OUTPUT:
index 6ab2ca0614dbb4d346cac0168e56de1360ca85c5..93f383fea9f114d03d7aaaa5414c472e6edfa6b9 100644 (file)
@@ -1,5 +1,5 @@
 // PERMUTE_ARGS:
-// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -w -o-
+// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -wi -o-
 /*
 TEST_OUTPUT:
 ---
index 1fbd6a9cbe847c815b38b0c4d9c926285b34d39e..b5cfa86367c1a232014044a11a73d95a23598c5e 100644 (file)
@@ -1,5 +1,5 @@
 // PERMUTE_ARGS:
-// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -w -o-
+// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -wi -o-
 
 /*
 TEST_OUTPUT:
index 3b283427951f1dc7a60da30b15b0122e05a972de..82b93adf1f65306c6d6940af4617e2bca68ae0cd 100644 (file)
@@ -612,13 +612,7 @@ extern(C++)
 
 version (CRuntime_Microsoft)
 {
-    struct __c_long_double
-    {
-        this(double d) { ld = d; }
-        double ld;
-        alias ld this;
-    }
-
+    enum __c_long_double : double;
     alias __c_long_double myld;
 }
 else
@@ -655,20 +649,8 @@ else
   }
 }
 
-struct __c_long
-{
-    this(x_long d) { ld = d; }
-    x_long ld;
-    alias ld this;
-}
-
-struct __c_ulong
-{
-    this(x_ulong d) { ld = d; }
-    x_ulong ld;
-    alias ld this;
-}
-
+enum __c_long : x_long;
+enum __c_ulong : x_ulong;
 alias __c_long mylong;
 alias __c_ulong myulong;
 
@@ -688,6 +670,43 @@ void test16()
     ld = testul(ld);
     assert(ld == 5 + myulong.sizeof);
   }
+
+  static if (__c_long.sizeof == long.sizeof)
+  {
+    static assert(__c_long.max == long.max);
+    static assert(__c_long.min == long.min);
+    static assert(__c_long.init == long.init);
+    static assert(__c_ulong.max == ulong.max);
+    static assert(__c_ulong.min == ulong.min);
+    static assert(__c_ulong.init == ulong.init);
+    __c_long cl = 0;
+    cl = cl + 1;
+    long l = cl;
+    cl = l;
+    __c_ulong cul = 0;
+    cul = cul + 1;
+    ulong ul = cul;
+    cul = ul;
+  }
+  else static if (__c_long.sizeof == int.sizeof)
+  {
+    static assert(__c_long.max == int.max);
+    static assert(__c_long.min == int.min);
+    static assert(__c_long.init == int.init);
+    static assert(__c_ulong.max == uint.max);
+    static assert(__c_ulong.min == uint.min);
+    static assert(__c_ulong.init == uint.init);
+    __c_long cl = 0;
+    cl = cl + 1;
+    int i = cl;
+    cl = i;
+    __c_ulong cul = 0;
+    cul = cul + 1;
+    uint u = cul;
+    cul = u;
+  }
+  else
+    static assert(0);
 }
 
 /****************************************/