Re: [PATCH] testsuite: Add check_effective_target_d_runtime_has_std_library procedure

2020-04-18 Thread Iain Buclaw via Gcc-patches
On 15/04/2020 17:26, Rainer Orth wrote:
> Hi Richard,
> 
>> Iain Buclaw via Gcc-patches  writes:
>>> Hi,
>>>
>>> This patch adds an effect target d_runtime_has_std_library to
>>> target-supports.exp, and some preliminary uses of it.
>>>
>>> The current check_effective_target_d_runtime procedure returns false if
>>> the target is without any core runtime library for D.  This additional
>>> procedure is for targets where the core runtime library exists, but is
>>> without the higher level standard D library.
>>>
>>> OK for master?
>>
>> OK.  FAOD though, D-related effective-target keywords are covered by the
>> D frontend maintainership.
> 
> indeed.  However, they still need documenting in sourcebuild.texi.  Iain,
> please do so before committing.
> 

Thanks, committed with added documentation, attached the updated patch.

Iain.

---
gcc/ChangeLog:

* doc/sourcebuild.texi (Effective-Target Keywords, Environment
attributes): Document d_runtime_has_std_library.

gcc/testsuite/ChangeLog:

* gdc.dg/link.d: Use d_runtime_has_std_library effective target.
* gdc.dg/runnable.d: Move phobos tests to...
* gdc.dg/runnable2.d: ...here.  New test.
* lib/target-supports.exp
(check_effective_target_d_runtime_has_std_library): New.

libphobos/ChangeLog:

* testsuite/libphobos.phobos/phobos.exp: Skip if effective target is
not d_runtime_has_std_library.
* testsuite/libphobos.phobos_shared/phobos_shared.exp: Likewise.
---
 gcc/doc/sourcebuild.texi  |   3 +
 gcc/testsuite/gdc.dg/link.d   |   2 +-
 gcc/testsuite/gdc.dg/runnable.d   | 229 
 gcc/testsuite/gdc.dg/runnable2.d  | 244 ++
 gcc/testsuite/lib/target-supports.exp |  15 ++
 .../testsuite/libphobos.phobos/phobos.exp |   5 +
 .../libphobos.phobos_shared/phobos_shared.exp |   5 +
 7 files changed, 273 insertions(+), 230 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/runnable2.d

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index de28227236a..c1642bad398 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2207,6 +2207,9 @@ overloads for @code{strchr} etc. functions.
 @item d_runtime
 Target provides the D runtime.
 
+@item d_runtime_has_std_library
+Target provides the D standard library (Phobos).
+
 @item dummy_wcsftime
 Target uses a dummy @code{wcsftime} function that always returns zero.
 
diff --git a/gcc/testsuite/gdc.dg/link.d b/gcc/testsuite/gdc.dg/link.d
index a8ca4ed5cb6..5efd0ad347f 100644
--- a/gcc/testsuite/gdc.dg/link.d
+++ b/gcc/testsuite/gdc.dg/link.d
@@ -1,4 +1,4 @@
-// { dg-do link { target d_runtime } }
+// { dg-do link { target d_runtime_has_std_library } }
 
 /**/
 
diff --git a/gcc/testsuite/gdc.dg/runnable.d b/gcc/testsuite/gdc.dg/runnable.d
index 484a9709bf3..7307e09a645 100644
--- a/gcc/testsuite/gdc.dg/runnable.d
+++ b/gcc/testsuite/gdc.dg/runnable.d
@@ -9,20 +9,6 @@ import core.stdc.stdio;
 import gcc.attribute;
 
 
-/**/
-// https://bugzilla.gdcproject.org/show_bug.cgi?id=2
-
-struct S
-{
-string toString() { return "foo"; }
-}
-
-void test2()
-{
-import std.string : format;
-assert(format("%s", S()) == "foo");
-}
-
 /**/
 // https://bugzilla.gdcproject.org/show_bug.cgi?id=4
 
@@ -33,35 +19,6 @@ void test4()
 static assert(!__traits(compiles, str.sort));
 }
 
-/**/
-// https://bugzilla.gdcproject.org/show_bug.cgi?id=15
-
-class B
-{
-class A { }
-A a;
-}
-
-class C
-{
-void visit(B b)
-{
-import std.algorithm : map;
-auto as = [b.a];
-as.map!(d => d);
-}
-}
-
-/**/
-// https://bugzilla.gdcproject.org/show_bug.cgi?id=16
-
-void test16()
-{
-import std.parallelism : taskPool;
-
-taskPool.reduce!"a+b"([0, 1, 2, 3]);
-}
-
 /**/
 // https://bugzilla.gdcproject.org/show_bug.cgi?id=17
 
@@ -99,59 +56,6 @@ void test17()
   (new ModuleWriter()).save ("test.0.mci");
 }
 
-/**/
-// https://bugzilla.gdcproject.org/show_bug.cgi?id=18
-
-class C18
-{
-struct Link
-{
-int x;
-int y;
-}
-
-void sort_links()
-{
-import std.algorithm : sort;
-import std.array : empty;
-import std.exception : enforce;
-
-enforce(!_link.empty);
-
-bool lt(Link a, Link b)
-{
-if(a.x > b.x)
-return false;
-if(a.x < b.x)
-return true;
-if(a.y >= b.y)
-return false;
-else
-return true;
-}
-sort!(lt)(_link);
-}
-
-this()
-{
-_link ~= Link(8, 3);
-_link ~= Link(4, 7);
-_link 

Re: [PATCH] testsuite: Add check_effective_target_d_runtime_has_std_library procedure

2020-04-15 Thread Iain Buclaw via Gcc-patches



On 15/04/2020 17:17, Richard Sandiford wrote:
> Iain Buclaw via Gcc-patches  writes:
>> Hi,
>>
>> This patch adds an effect target d_runtime_has_std_library to
>> target-supports.exp, and some preliminary uses of it.
>>
>> The current check_effective_target_d_runtime procedure returns false if
>> the target is without any core runtime library for D.  This additional
>> procedure is for targets where the core runtime library exists, but is
>> without the higher level standard D library.
>>
>> OK for master?
> 
> OK.  FAOD though, D-related effective-target keywords are covered by the
> D frontend maintainership.
> 

Ah, thanks for clarifying that, I wasn't sure, but thought it best to pass it 
by for review just in case.

Iain.


Re: [PATCH] testsuite: Add check_effective_target_d_runtime_has_std_library procedure

2020-04-15 Thread Rainer Orth
Hi Richard,

> Iain Buclaw via Gcc-patches  writes:
>> Hi,
>>
>> This patch adds an effect target d_runtime_has_std_library to
>> target-supports.exp, and some preliminary uses of it.
>>
>> The current check_effective_target_d_runtime procedure returns false if
>> the target is without any core runtime library for D.  This additional
>> procedure is for targets where the core runtime library exists, but is
>> without the higher level standard D library.
>>
>> OK for master?
>
> OK.  FAOD though, D-related effective-target keywords are covered by the
> D frontend maintainership.

indeed.  However, they still need documenting in sourcebuild.texi.  Iain,
please do so before committing.

Thanks.
Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH] testsuite: Add check_effective_target_d_runtime_has_std_library procedure

2020-04-15 Thread Richard Sandiford
Iain Buclaw via Gcc-patches  writes:
> Hi,
>
> This patch adds an effect target d_runtime_has_std_library to
> target-supports.exp, and some preliminary uses of it.
>
> The current check_effective_target_d_runtime procedure returns false if
> the target is without any core runtime library for D.  This additional
> procedure is for targets where the core runtime library exists, but is
> without the higher level standard D library.
>
> OK for master?

OK.  FAOD though, D-related effective-target keywords are covered by the
D frontend maintainership.

Thanks,
Richard


>
> Regards
> Iain.
>
> ---
> gcc/testsuite/ChangeLog:
>
>   * gdc.dg/link.d: Use d_runtime_has_std_library effective target.
>   * gdc.dg/runnable.d: Move phobos tests to...
>   * gdc.dg/runnable2.d: ...here.  New test.
>   * lib/target-supports.exp
>   (check_effective_target_d_runtime_has_std_library): New.
>
> libphobos/ChangeLog:
>
>   * testsuite/libphobos.phobos/phobos.exp: Skip if effective target is
>   not d_runtime_has_std_library.
>   * testsuite/libphobos.phobos_shared/phobos_shared.exp: Likewise.
> ---
>  gcc/testsuite/gdc.dg/link.d   |   2 +-
>  gcc/testsuite/gdc.dg/runnable.d   | 229 
>  gcc/testsuite/gdc.dg/runnable2.d  | 244 ++
>  gcc/testsuite/lib/target-supports.exp |  15 ++
>  .../testsuite/libphobos.phobos/phobos.exp |   5 +
>  .../libphobos.phobos_shared/phobos_shared.exp |   5 +
>  6 files changed, 270 insertions(+), 230 deletions(-)
>  create mode 100644 gcc/testsuite/gdc.dg/runnable2.d
>
> diff --git a/gcc/testsuite/gdc.dg/link.d b/gcc/testsuite/gdc.dg/link.d
> index a8ca4ed5cb6..5efd0ad347f 100644
> --- a/gcc/testsuite/gdc.dg/link.d
> +++ b/gcc/testsuite/gdc.dg/link.d
> @@ -1,4 +1,4 @@
> -// { dg-do link { target d_runtime } }
> +// { dg-do link { target d_runtime_has_std_library } }
>  
>  /**/
>  
> diff --git a/gcc/testsuite/gdc.dg/runnable.d b/gcc/testsuite/gdc.dg/runnable.d
> index 484a9709bf3..7307e09a645 100644
> --- a/gcc/testsuite/gdc.dg/runnable.d
> +++ b/gcc/testsuite/gdc.dg/runnable.d
> @@ -9,20 +9,6 @@ import core.stdc.stdio;
>  import gcc.attribute;
>  
>  
> -/**/
> -// https://bugzilla.gdcproject.org/show_bug.cgi?id=2
> -
> -struct S
> -{
> -string toString() { return "foo"; }
> -}
> -
> -void test2()
> -{
> -import std.string : format;
> -assert(format("%s", S()) == "foo");
> -}
> -
>  /**/
>  // https://bugzilla.gdcproject.org/show_bug.cgi?id=4
>  
> @@ -33,35 +19,6 @@ void test4()
>  static assert(!__traits(compiles, str.sort));
>  }
>  
> -/**/
> -// https://bugzilla.gdcproject.org/show_bug.cgi?id=15
> -
> -class B
> -{
> -class A { }
> -A a;
> -}
> -
> -class C
> -{
> -void visit(B b)
> -{
> -import std.algorithm : map;
> -auto as = [b.a];
> -as.map!(d => d);
> -}
> -}
> -
> -/**/
> -// https://bugzilla.gdcproject.org/show_bug.cgi?id=16
> -
> -void test16()
> -{
> -import std.parallelism : taskPool;
> -
> -taskPool.reduce!"a+b"([0, 1, 2, 3]);
> -}
> -
>  /**/
>  // https://bugzilla.gdcproject.org/show_bug.cgi?id=17
>  
> @@ -99,59 +56,6 @@ void test17()
>(new ModuleWriter()).save ("test.0.mci");
>  }
>  
> -/**/
> -// https://bugzilla.gdcproject.org/show_bug.cgi?id=18
> -
> -class C18
> -{
> -struct Link
> -{
> -int x;
> -int y;
> -}
> -
> -void sort_links()
> -{
> -import std.algorithm : sort;
> -import std.array : empty;
> -import std.exception : enforce;
> -
> -enforce(!_link.empty);
> -
> -bool lt(Link a, Link b)
> -{
> -if(a.x > b.x)
> -return false;
> -if(a.x < b.x)
> -return true;
> -if(a.y >= b.y)
> -return false;
> -else
> -return true;
> -}
> -sort!(lt)(_link);
> -}
> -
> -this()
> -{
> -_link ~= Link(8, 3);
> -_link ~= Link(4, 7);
> -_link ~= Link(4, 6);
> -_link ~= Link(3, 7);
> -_link ~= Link(2, 7);
> -_link ~= Link(2, 2);
> -_link ~= Link(4, 1);
> -}
> -
> -Link[] _link;
> -}
> -
> -void test18()
> -{
> -C18 foo = new C18;
> -foo.sort_links();
> -}
> -
>  /**/
>  // https://bugzilla.gdcproject.org/show_bug.cgi?id=19
>  
> @@ -177,22 +81,6 @@ void test24()
>  return;
>  }
>  
> -/**/
> -// https://bugzilla.gdcproject.org/show_bug.cgi?id=29
> -
> -void test29()
> -{
> -import std.string : format;
> -import std.conv : text;
> -
> -string 

[PATCH] testsuite: Add check_effective_target_d_runtime_has_std_library procedure

2020-04-14 Thread Iain Buclaw via Gcc-patches
Hi,

This patch adds an effect target d_runtime_has_std_library to
target-supports.exp, and some preliminary uses of it.

The current check_effective_target_d_runtime procedure returns false if
the target is without any core runtime library for D.  This additional
procedure is for targets where the core runtime library exists, but is
without the higher level standard D library.

OK for master?

Regards
Iain.

---
gcc/testsuite/ChangeLog:

* gdc.dg/link.d: Use d_runtime_has_std_library effective target.
* gdc.dg/runnable.d: Move phobos tests to...
* gdc.dg/runnable2.d: ...here.  New test.
* lib/target-supports.exp
(check_effective_target_d_runtime_has_std_library): New.

libphobos/ChangeLog:

* testsuite/libphobos.phobos/phobos.exp: Skip if effective target is
not d_runtime_has_std_library.
* testsuite/libphobos.phobos_shared/phobos_shared.exp: Likewise.
---
 gcc/testsuite/gdc.dg/link.d   |   2 +-
 gcc/testsuite/gdc.dg/runnable.d   | 229 
 gcc/testsuite/gdc.dg/runnable2.d  | 244 ++
 gcc/testsuite/lib/target-supports.exp |  15 ++
 .../testsuite/libphobos.phobos/phobos.exp |   5 +
 .../libphobos.phobos_shared/phobos_shared.exp |   5 +
 6 files changed, 270 insertions(+), 230 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/runnable2.d

diff --git a/gcc/testsuite/gdc.dg/link.d b/gcc/testsuite/gdc.dg/link.d
index a8ca4ed5cb6..5efd0ad347f 100644
--- a/gcc/testsuite/gdc.dg/link.d
+++ b/gcc/testsuite/gdc.dg/link.d
@@ -1,4 +1,4 @@
-// { dg-do link { target d_runtime } }
+// { dg-do link { target d_runtime_has_std_library } }
 
 /**/
 
diff --git a/gcc/testsuite/gdc.dg/runnable.d b/gcc/testsuite/gdc.dg/runnable.d
index 484a9709bf3..7307e09a645 100644
--- a/gcc/testsuite/gdc.dg/runnable.d
+++ b/gcc/testsuite/gdc.dg/runnable.d
@@ -9,20 +9,6 @@ import core.stdc.stdio;
 import gcc.attribute;
 
 
-/**/
-// https://bugzilla.gdcproject.org/show_bug.cgi?id=2
-
-struct S
-{
-string toString() { return "foo"; }
-}
-
-void test2()
-{
-import std.string : format;
-assert(format("%s", S()) == "foo");
-}
-
 /**/
 // https://bugzilla.gdcproject.org/show_bug.cgi?id=4
 
@@ -33,35 +19,6 @@ void test4()
 static assert(!__traits(compiles, str.sort));
 }
 
-/**/
-// https://bugzilla.gdcproject.org/show_bug.cgi?id=15
-
-class B
-{
-class A { }
-A a;
-}
-
-class C
-{
-void visit(B b)
-{
-import std.algorithm : map;
-auto as = [b.a];
-as.map!(d => d);
-}
-}
-
-/**/
-// https://bugzilla.gdcproject.org/show_bug.cgi?id=16
-
-void test16()
-{
-import std.parallelism : taskPool;
-
-taskPool.reduce!"a+b"([0, 1, 2, 3]);
-}
-
 /**/
 // https://bugzilla.gdcproject.org/show_bug.cgi?id=17
 
@@ -99,59 +56,6 @@ void test17()
   (new ModuleWriter()).save ("test.0.mci");
 }
 
-/**/
-// https://bugzilla.gdcproject.org/show_bug.cgi?id=18
-
-class C18
-{
-struct Link
-{
-int x;
-int y;
-}
-
-void sort_links()
-{
-import std.algorithm : sort;
-import std.array : empty;
-import std.exception : enforce;
-
-enforce(!_link.empty);
-
-bool lt(Link a, Link b)
-{
-if(a.x > b.x)
-return false;
-if(a.x < b.x)
-return true;
-if(a.y >= b.y)
-return false;
-else
-return true;
-}
-sort!(lt)(_link);
-}
-
-this()
-{
-_link ~= Link(8, 3);
-_link ~= Link(4, 7);
-_link ~= Link(4, 6);
-_link ~= Link(3, 7);
-_link ~= Link(2, 7);
-_link ~= Link(2, 2);
-_link ~= Link(4, 1);
-}
-
-Link[] _link;
-}
-
-void test18()
-{
-C18 foo = new C18;
-foo.sort_links();
-}
-
 /**/
 // https://bugzilla.gdcproject.org/show_bug.cgi?id=19
 
@@ -177,22 +81,6 @@ void test24()
 return;
 }
 
-/**/
-// https://bugzilla.gdcproject.org/show_bug.cgi?id=29
-
-void test29()
-{
-import std.string : format;
-import std.conv : text;
-
-string s;
-for (auto i = 0; i < 10; i++)
-{
-s = format("%d", i);
-s = text(i);
-}
-}
-
 /**/
 // https://bugzilla.gdcproject.org/show_bug.cgi?id=31
 
@@ -499,54 +387,6 @@ void test51()
 assert (s.x == 0);
 }
 
-/**/
-// https://bugzilla.gdcproject.org/show_bug.cgi?id=52
-
-class C52
-{
-C52 a;
-
-this()
-{
-printf("Construct: this=%p\n", cast(void*)this);
-a