From 5f49d2fc4e52398f04a39f81069bb5d1c21bb168 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Sun, 10 Mar 2019 21:55:30 +0000 Subject: [PATCH] re PR d/87824 (x86_64-linux multilib issues) PR d/87824 d/dmd: Merge upstream dmd fcc235e8e Associative arrays are value types, which are not covariant with the pointer type typeof(null). Updates https://gcc.gnu.org/PR87824 Reviewed-on: https://github.com/dlang/dmd/pull/9435 From-SVN: r269561 --- gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/mtype.c | 13 ++++++++++--- gcc/testsuite/gdc.test/runnable/nulltype.d | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) 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())(); } -- 2.30.2