This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, PR d/87824] Committed fix for failing test gdc.test/runnable/nulltype.d


This patch merges the D front-end implementation with dmd upstream
fcc235e8e, fixing the failing nulltype.d test with -m32 on
x86_64-linux.

Bootstrapped and regression tested on x86_64-linux-gnu with
RUNTESTFLAGS="--target_board=unix/\{,-m32\}".

Committed to trunk as r269561.

-- 
Iain
---
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 313748f70ae..cf5a22f070f 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-da26db81943952c7e35dab98650df589ec122485
+fcc235e8e25f7758266f7874edd5abefb9943e0b
 
 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/mtype.c b/gcc/d/dmd/mtype.c
index 2a23cab74fd..900f172cccb 100644
--- a/gcc/d/dmd/mtype.c
+++ b/gcc/d/dmd/mtype.c
@@ -5331,9 +5331,16 @@ int Type::covariant(Type *t, StorageClass *pstc, bool fix17349)
     }
     else if (t1n->ty == t2n->ty && t1n->implicitConvTo(t2n))
         goto Lcovariant;
-    else if (t1n->ty == Tnull && t1n->implicitConvTo(t2n) &&
-             t1n->size() == t2n->size())
-        goto Lcovariant;
+    else if (t1n->ty == Tnull)
+    {
+        // NULL is covariant with any pointer type, but not with any
+        // dynamic arrays, associative arrays or delegates.
+        // https://issues.dlang.org/show_bug.cgi?id=8589
+        // https://issues.dlang.org/show_bug.cgi?id=19618
+        Type *t2bn = t2n->toBasetype();
+        if (t2bn->ty == Tnull || t2bn->ty == Tpointer || t2bn->ty == Tclass)
+            goto Lcovariant;
+    }
   }
     goto Lnotcovariant;
 
diff --git a/gcc/testsuite/gdc.test/runnable/nulltype.d b/gcc/testsuite/gdc.test/runnable/nulltype.d
index 32d117468ee..c400d7f61f1 100644
--- a/gcc/testsuite/gdc.test/runnable/nulltype.d
+++ b/gcc/testsuite/gdc.test/runnable/nulltype.d
@@ -127,7 +127,7 @@ void test8589()
     {
         void f(T function() dg) { assert(!dg()); }
 
-        static assert((T.sizeof == typeof(null).sizeof) == result);
+        static assert((is(typeof(null) function() : T function())) == result);
         static assert(is(typeof( f(&retnull) )) == result);
         static assert(is(typeof( f(()=>null) )) == result);
         static if (result)
@@ -138,7 +138,7 @@ void test8589()
     }
     test!(true,  int*)();
     test!(true,  Object)();
-    test!(true,  int[int])();
+    test!(false, int[int])();
     test!(false, int[])();
     test!(false, void delegate())();
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]