From 70d2d77700744378ed1a4c6888c510781cd717ac Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Sun, 24 Mar 2019 16:20:43 +0000 Subject: [PATCH] d/dmd: Merge upstream dmd 74ac873be Introduces a fix for a segfault when building without object.d being present, as well as MinGW host build errors in dmd/root/filename.c. Updates a couple of non-portable tests, removing one and fixing the other. From-SVN: r269897 --- gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/dmodule.c | 2 +- gcc/d/dmd/root/filename.c | 7 ++- .../gdc.test/fail_compilation/fail6451.d | 18 ------ gcc/testsuite/gdc.test/runnable/test4.d | 60 +++++++------------ 5 files changed, 26 insertions(+), 63 deletions(-) delete mode 100644 gcc/testsuite/gdc.test/fail_compilation/fail6451.d diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 230fd12db2b..3017f0d34af 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -8d4c876c658608e8f6e653803c534a9e15618f57 +74ac873be1862090b7ec0e4a876fd1b758520359 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/dmodule.c b/gcc/d/dmd/dmodule.c index 20dbb69a91c..07e47127130 100644 --- a/gcc/d/dmd/dmodule.c +++ b/gcc/d/dmd/dmodule.c @@ -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 = FileName::canonicalName(global.inifilename); + const char *dmdConfFile = global.inifilename ? FileName::canonicalName(global.inifilename) : NULL; errorSupplemental(loc, "config file: %s", dmdConfFile ? dmdConfFile : "not found"); } else diff --git a/gcc/d/dmd/root/filename.c b/gcc/d/dmd/root/filename.c index 0e7b79db806..6144d810fb5 100644 --- a/gcc/d/dmd/root/filename.c +++ b/gcc/d/dmd/root/filename.c @@ -262,6 +262,7 @@ const char *FileName::name(const char *str) if (e == str + 1 || e == str + len - 1) return e + 1; #endif + /* falls through */ default: if (e == str) break; @@ -542,7 +543,7 @@ int FileName::exists(const char *name) int result; dw = GetFileAttributesA(name); - if (dw == -1L) + if (dw == INVALID_FILE_ATTRIBUTES) result = 0; else if (dw & FILE_ATTRIBUTE_DIRECTORY) result = 2; @@ -568,7 +569,7 @@ bool FileName::ensurePathExists(const char *path) size_t len = strlen(path); if ((len > 2 && p[-1] == ':' && strcmp(path + 2, p) == 0) || len == strlen(p)) - { mem.xfree(const_cast(p)); + { mem.xfree(const_cast(p)); return 0; } #endif @@ -621,7 +622,7 @@ const char *FileName::canonicalName(const char *name) DWORD result = GetFullPathNameA(name, 0, NULL, NULL); if (result) { - char *buf = (char *)malloc(result); + char *buf = (char *)mem.xmalloc(result); result = GetFullPathNameA(name, result, buf, NULL); if (result == 0) { diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail6451.d b/gcc/testsuite/gdc.test/fail_compilation/fail6451.d deleted file mode 100644 index 54c628ac075..00000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/fail6451.d +++ /dev/null @@ -1,18 +0,0 @@ - -version(GNU) -{ - static assert(0); -} -version(Win64) -{ - static assert(0); -} -else version(X86_64) -{ - void error(...){} -} -else -{ - static assert(0); -} - diff --git a/gcc/testsuite/gdc.test/runnable/test4.d b/gcc/testsuite/gdc.test/runnable/test4.d index f008da6da72..b5263e7a9d1 100644 --- a/gcc/testsuite/gdc.test/runnable/test4.d +++ b/gcc/testsuite/gdc.test/runnable/test4.d @@ -224,46 +224,26 @@ void test6() assert(&t.Bottom < &t.foo2); assert(TRECT6.foo1.offsetof == 0); -version (Win32) -{ - assert(TRECT6.Left.offsetof == 8); - assert(TRECT6.Top.offsetof == 12); - assert(TRECT6.Right.offsetof == 16); - assert(TRECT6.Bottom.offsetof == 20); - assert(TRECT6.TopLeft.offsetof == 8); - assert(TRECT6.BottomRight.offsetof == 16); - assert(TRECT6.foo2.offsetof == 24); -} -else version (X86_64) -{ - assert(TRECT6.Left.offsetof == 8); - assert(TRECT6.Top.offsetof == 12); - assert(TRECT6.Right.offsetof == 16); - assert(TRECT6.Bottom.offsetof == 20); - assert(TRECT6.TopLeft.offsetof == 8); - assert(TRECT6.BottomRight.offsetof == 16); - assert(TRECT6.foo2.offsetof == 24); -} -else version(ARM) -{ - assert(TRECT6.Left.offsetof == 8); - assert(TRECT6.Top.offsetof == 12); - assert(TRECT6.Right.offsetof == 16); - assert(TRECT6.Bottom.offsetof == 20); - assert(TRECT6.TopLeft.offsetof == 8); - assert(TRECT6.BottomRight.offsetof == 16); - assert(TRECT6.foo2.offsetof == 24); -} -else -{ - assert(TRECT6.Left.offsetof == 4); - assert(TRECT6.Top.offsetof == 8); - assert(TRECT6.Right.offsetof == 12); - assert(TRECT6.Bottom.offsetof == 16); - assert(TRECT6.TopLeft.offsetof == 4); - assert(TRECT6.BottomRight.offsetof == 12); - assert(TRECT6.foo2.offsetof == 20); -} + static if (long.alignof == 8) + { + assert(TRECT6.Left.offsetof == 8); + assert(TRECT6.Top.offsetof == 12); + assert(TRECT6.Right.offsetof == 16); + assert(TRECT6.Bottom.offsetof == 20); + assert(TRECT6.TopLeft.offsetof == 8); + assert(TRECT6.BottomRight.offsetof == 16); + assert(TRECT6.foo2.offsetof == 24); + } + else + { + assert(TRECT6.Left.offsetof == 4); + assert(TRECT6.Top.offsetof == 8); + assert(TRECT6.Right.offsetof == 12); + assert(TRECT6.Bottom.offsetof == 16); + assert(TRECT6.TopLeft.offsetof == 4); + assert(TRECT6.BottomRight.offsetof == 12); + assert(TRECT6.foo2.offsetof == 20); + } } /* ================================ */ -- 2.30.2